12. Append to Body


This is my code but I can't pass the lesson!!! Is there anything wrong with it?

        var toAdd = $("input[name='checkListItem']").val();
        $('.list').append('<div class="list">' + toAdd + '</div>');


.append() a <div> with class="item" to the .list div

but you've write list class
$('.list').append('<div class="list">' + toAdd + '</div>');

should be class="item"



' + toAdd + '
It is already appending in the
with list class [$('.list').append]. so you do not need to tell again inside the .append object [.append('
]. find an example below-

This code will add the input item to message div as

, test the code with different tag, i.e. h4 tag or li tag , so you will understand the difference.

Happy Coding :slight_smile:


in your html should be

' + toAdd + '


Is an issue also in enclosing checkListItem in quotes? example: var toAdd = $("input[name='checkListItem']").val();

In the previous exercise we were not expected to use quotes. example: var toAdd = $("input[name=checkListItem]").val();