13/14 i dont know where to put the .on() string


So my code is..

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

But I need to add...

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

(i dont think i wrote that right so please correct it)

Where do I put it?


Hi Rachel,

You'll need to add the new code after $('#button').click(function() {...});, but still inside the $(document).ready(function() {...}); :)

And the correct way to write that would be:

$(document).on("click", '.item', function() {
  // code here


Technically, this line does not need to be deferred since it is not waiting for any elements to load. The document is already present so this handler can be outside of the ready() handler. However, in keeping with the instructions, your advice is good and valid, @zystvan.


$(document).on('click', '.item', function() {
    // event handler code
    // deferred code


@mtf Notice that concatenating that way won't be evaluated as a correct answer (came from the exercise to report the bug).


It's not really meant as one, more to demonstrate that deferral is not required for the listener.


A post was split to a new topic: Where is a bug?


var toAdd = $('input[name=checkListItem]').val();

$(document).on("click", '.item', function() {
// code