Mastering Manipulations (3/10-3/14), passing the lessons but not working?


#1

The object of this lesson is to create a To Do List that adds items via the append() function and the on() function to remove them. So the code below is what I have submitted. It has passed the lesson but when I test it in the test browser, nothing happens. Just curious if this has happened to anyone else.

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


#2

Hi,

I have the same problem - it shows me that I made everything right but my code doesn't work at all...
I noticed that you have $(".button").click(function { in your code. It should be #button instead of class, shouldn't it? Button is an id, not a class...


#3

 $(".button").click

you are selecting a id not a class so your have to select like

$("#button").click

now

.click(function { //here need a parameter before {

like

.click(function (){

next

var toAdd = $('input[name=checkListItem]');

you didn't use .val( )method .you should use it to get the values of form elements such as input, select and textarea.

your code should look like

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

next

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

here you have to select list class

so do like

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

next

$(document).on('click','.item', remove()

here need a function like

 $(document).on('click','.item', function() {
        (this).remove()
    });

#4

ah I see. Thanks very much!