12. Append to Body



Code is accepted; however, the following message appears: "Uncaught SyntaxError: missing ) after argument list".

What's wrong with my code?

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


item should be a printed string, not a variable. The double quotes need to be escaped.

Alternately, write the outer with a single quote so the HTML attribute quote writes as a double.

'<div class="item">' + toAdd + '</div>'


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