12. Append to body-- code apparently not working but accepted anyway


#1

The following code for adding a

to the body of the document was accepted, but I wonder if it's not working--when I click the Add button, nothing happens; in fact, the button doesn't seem to be clickable at all.

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

Can anyone tell me what is wrong with the above code?


Hello and i do not know the body element for make a website please help me
#2

Please post a link to the lesson so we can test your code. Thanks.

This is to the old course content, but I don't see where the new content is. We definitely could use a link.

https://www.codecademy.com/en/courses/web-beginner-en-v6phg/2/3


#3

The only thing unusual is the white space around the = sign. We don't normally write HTML this way, but it could be perfectly valid. Try removing the spaces and see what happens.


#4

Here is the link
https://www.codecademy.com/en/courses/web-beginner-en-v6phg/2/3?curriculum_id=50a3fad8c7a770b5fd0007a1to
the lesson.


#5

Your code does work as expected. Did you try entering some text before clicking add?


#6

Thank you! It seems I just misunderstood what the code was expected to do.


#7

A post was split to a new topic: Modifying HTML elements - code not appearing


#8

A post was split to a new topic: It wouldn't let me move forward:


#11