jQuery - on() method

.on() method can be though of .on() as a general handler that takes the event, its selector, and an action as inputs.

 $(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();    
   });  
 });  

No comments:

Post a Comment