13. Remove What's Been Clicked - Using a 2nd $(document)

<PLEASE USE THIS TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/en/courses/web-beginner-en-v6phg/2/4?curriculum_id=50a3fad8c7a770b5fd0007a1

<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>
Hey I’m just revisiting this exercise and I’m curious about why I have an $(document) inside of another.The code below passes the exercise, but is there better syntax for using .on()? Why is the document the selector twice in a row? Is this exercise meant to be done a different way?



$(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();
    });
});


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