views:

31

answers:

1

I am adding and removing items from a ul. However, I cannot remove items that were just added. I am assuming I need to register the event when the item is added. How to do this please?

+2  A: 

If you are registering an event handler for every li item in your ul, use the .live() function. This will register the same handler for every new li item that shows up on the page.

For example,

$("li").live("click", function(){
      $(this).remove();
    });

If this doesn't answer your question, could you edit it to be a bit more clear about what you're trying to do?

womp
worked. thanks....
zsharp