Remove What's been Clicked - Bug


#1


The exercise is: "Remove What's Been Clicked" : https://www.codecademy.com/en/courses/web-beginner-en-v6phg/2/4?curriculum_id=50a3fad8c7a770b5fd0007a1


I believe there is a bug - the following code registers as correct when I Save and Submit, but I cannot execute a removal of an item in the live demo window.

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

    $(this).on('click', '.item', .remove());

})

This is what the page looks like when (i believe) it is erring:

Thank you for taking a look - please let me know how my code is wrong if this is not really a bug.


#2

We need a binding to the document or .list, then delegate the event.

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

#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.