14.YOU DID IT. Yes i did it but


#1

Here is my code, all the steps seems right and i can pass the lessons:

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

" + toAdd + "
");
});
$(document).on("click",".item", function() {
$(this).remove();
});

THE QUESTION:
Why if my code work i cant click the Add button and cant add any information ?
I checked before other topics and the codes seems equal to mine.


#2

Hi david,

Compare how you're selecting #button and .list, to how you're selecting document or this. You're missing the dollar sign ($) in front of some of your selectors, which is why it's not working.


#3

Thanks zystvan, but still doesn't work, here is the new code:

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

#4

@jamona The problem is on this line:

The quotes surrounding item are un-quoting it and causing a syntax error. You can either escape the quotes by adding a backslash (\) in front of each quote you don't want registered, or you can use single quotes around everything else :slight_smile:


#5

$(".list").append("

" + toAdd + "
");
ty zystvan, that was the problem, resolved , you are a young master :wink:

#6