Steps 3 and 4, removing the added items


I can toggle the star and remove the preadded items, but when I add test items, I can toggle the star or remove them. I have looked at the other topics and tried various codes. The below code is the best I have to date. but still will not remove new items or toggle their star.


var template = function(text) {
  return '<p><input type="checkbox"><i class="glyphicon glyphicon-star"></i><span>' + text + '</span><i class="glyphicon glyphicon-remove"></i></p>';

var main = function() {
  $('form').submit(function() {
  var text = $('#todo').val();    
  var html = template(text);
    return false;  
  $('.glyphicon-star').on('click', function() {
  $('.glyphicon-remove').on('click', function() {



When using on() specify the parent element in the selector, and write the delegated element in the argument list. Since we selecting the same parent, we can chain the two listeners...

  $('.list').on('click','.glyphicon-star', function(){

This will maintain the bindings on .list when items are removed.


Thank you very much!! I thought I had tried that, but I must have either mistyped or left something out when I did. I appreciate the fast help!


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