Removing a dynamically created li from ul

前端 未结 4 1107
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-07 05:31

I\'m using jquery to add and remove bullets on the fly after the DOM is loaded.

Here\'s the code to add a bullet which works fine:

// add bullet
$(\'         


        
4条回答
  •  猫巷女王i
    2021-01-07 05:43

    Replace the following:

    $('#linkedEventList ul').append('
  • ' + datum.headline + ' (x) (open)
  • ');

    with this:

    $('#linkedEventList ul').append('
  • ' + datum.headline + ' (x) (open)
  • '); $('#'+datum._id).bind({ click: function(o) { $(this).remove(); } });

    Hope this helps.

提交回复
热议问题