12. Append to Body


#1


Hi, I've tried searching for the error in my code but cannot find it.Can anyone please point out the mistake?

I received the error message:

"Uncaught SyntaxError: missing ) after argument list"


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


#2

here:

"<div class="item">"

you need to use + to join/concatenate variable and string together just like you did with toAdd


#5

Use alternate quotation marks like this:

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

instead of your:

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

#7

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.