Hi Dimby,
your problem is very easy; you are creating a new element, a new '<li>', but it does not have an event attached. It's a beginner mistake.
You only need to change one line:
$('a.remove').live ('click', function() {
var id= $(this).attr('id');
$('li#'+id).fadeOut('fast', function(){ $('li #'+id).remove(); });
i--;
});
Now, when a new element is added, the event 'click' is attached to it and works fine.
Bye.
> Date: Fri, 27 Feb 2009 06:31:29 -0800
> Subject: [jQuery] Remove doenst work on dynamically created li
> From: pauldulong@gmail.com
> To: jquery-en@googlegroups.com
>
>
> Hi,
>
> I'm new, so to all of you HELLO Smile.
> Btw, im Dutch so maybe my English isnt that good.
> I love Jquery but i've got some starting problems.
>
> Live demo:
> http://pauldulong.nl/jquery/dgm.php#
>
> When I click on the X the tab disappears, perfect, as it should be.
> But when I create a new tab and try to remove that one it doesn't do
> anything.
>
> What im I doing wrong?
>
> Dimby - Paul du long
Get news, entertainment and everything you care about at Live.com. Check it out!
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment