Remove What's Been Clicked


#1


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


See error message in attached screenshot.
What makes me confused:
1. It throws error, even though I can go to next lesson;
2. Does the event must be in quotation marks. In our case -> would that be correct if I used '.click()' instead of .click().
And why is so?


$(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

The lesson validation is not always perfect

on line 2, .click() is a function call which triggers something.

on line 6, "click" is an argument of the .on() function call. .on() expects the event it is suppose to handle to be a string.

So .click() is a function call, where as "click" is an argument for the .on() function call

jquery - on
jquery - click


#3

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