12. Append To Body


#1

Hi all,

I'm getting a pass for my code below on exercise 12, but it's not actually doing anything when I click the Add button.

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

I think the code is probably wrong, but I can't see how. Can anyone help me with it please?

Thanks!


#2

I'd missed off a concatenation + from the 4th line, but now it's just adding [object Object] to the list, so another problem!


#3

@devblaster44527 Good catch - now all you need to do is grab the value of the input field :wink:

Hint

Like this:

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


#4

Doh! Of course. All working now. Thank you!


#6