Where does item come in to play. Is it a reference to <li> in some way even though we don't have a list in our html?


#1

Here's my code that works:

$(document).ready(function(){
$('#button').click(function(){
var toAdd = $('input[name=checkListItem]').val();
$('.list').append('

' + toAdd + '
');
});
});

I understand that I'm selecting the class list and I want to append a div with a class name of item and my variable toAdd with the user input stored in it. But where is the .item class coming from. I have no div in my HTML with a class name of item. Is this a reference somehow to name=checkListItem. I can't see it referring to a

  • because there is no list in our code. I'm confused. Maybe I'm missing something simple I don't know?

  • #2

    Referring back to my question. Am I creating a new div with a class name item? That is the only thing that I could think of that makes sense.


    #3

    Hi, Yes they aske you to create a new <div> with jQuery so like you started

    $('.list').append('
    
    ' + toAdd + '
    ');

    You should finish it like that

    $('.list').append('<div class="item">' + toAdd + '</div>');