Removing elements in todo list


#1

https://www.codecademy.com/en/courses/web-beginner-en-v6phg/2/4?curriculum_id=50a3fad8c7a770b5fd0007a1

Uncaught ReferenceError: remove is not defined



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



#2

look at .on() documentation:

http://api.jquery.com/on/

the the third argument should be a function, here is an example from the docs:

$( "#dataTable tbody" ).on( "click", "tr", function() {
  console.log( $( this ).text() );
});

inside the function you can then remove the element


#3

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