Mastering manipulations


#1



https://www.codecademy.com/courses/web-beginner-en-v6phg/2/5?curriculum_id=50a3fad8c7a770b5fd0007a1


I passed the section but the code does not work. I cannot add to the list and I cannot remove from the list


$(document).ready(function() {
    $('#button').click(function() {
    var toAdd = $('input [name=checkListItem]').val();
    $(".list").append('<div class="item">' + toAdd + '</div');
    )};
        $(document).on('click','.item',function () {
            $(this).remove();
            )};
    )};


#2

Remove white space between input and [.

Being as this is inside the ready() handler,

    $(document).on('click','.item',function () {
        $(this).remove();
    )};

we can bind it to .list,

    $('.list').on('click','.item',function () {
        $(this).remove();
    )};

That will restrict the remove() method to just .item in .list, and not affect any other items of class item.