Append to Body: Code my is not working ... but was excepted anyway


#1

this is the code i used

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

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

and i got the error

"Uncaught SyntaxError: Unexpected identifier"

when i click the add div nothing happens but if i submit it still says "Way to go! Start Next Lesson"

any ideas?

teddy


#2

I don't know why it is accepting your code, but you have forgotten a ')' on line 2 after function. If you run it with the ) it should run normally.


#3

Thank you, is always the small stuff you miss that dose it, lol


#4

Any ideas on this one... its adding to my added div list.. just not adding the input properly?


#5

Nothing big is going on here either, I guess. You should write checkListItem with 2 capital letters; See if that works


#6

The reason it's not working is because your [name=checklistItem] is wrong, it should be checkListItem. Notice the camel case on the L! That should fix it!


#7

I don't understand this one at all. The way the directions read to me it means I am supposed to add a new class to the div AND also add the new item from the variable. How do you add both with append? I don't understand the directions.


#9