Thanks a lot guys! Works like a charm now!
On Jul 7, 4:42 pm, "Cesar Sanz" <the.email.tr...@gmail.com> wrote: > Hello > > Liam is right, try "live" > > The reason your attempt does not work is beacause you bind your event to an > existing element at first, but then, when you create a new one, the event is > not aware of this new > element. Using live, it checks elements (old and new ones) to ensure the > event is bind correctly. > > Cheers > > ----- Original Message ----- > From: "Liam Potter" <radioactiv...@gmail.com> > To: <jquery-en@googlegroups.com> > Sent: Tuesday, July 07, 2009 3:58 AM > Subject: [jQuery] Re: $("delButton")..click(function(){... for later added > > button's > > > live should work, try this. > > > $(".delButton").live("click", function(){ > > $(this).parent(".parentOFbutton").remove(); > > return false; > > }); > > > pascal.nauj...@googlemail.com wrote: > >> Hi, > > >> i implemented the following method for removing a button with it's > >> parent: > > >> $(".delButton").click(function(event){ > >> event.preventDefault(); > >> $(this).parent(".parentOFbutton").remove(); > >> }); > > >> this works fine. > > >> Now i added a script which dynamicly adds those "delButton"s to my dom- > >> tree with when the user creates a new record: > > >> $(".parentOFbutton:last").append(' [<a href=\#" class="delButton">DEL</ > >> a>]'); > > >> This also works. > > >> But now my $(".delButton").click(function(event){ ... doesn't! Is this > >> cause of appending the buttons on the runtime of the script? Is there > >> a workaround? I found and tried the "live" method from jquery (http:// > >> docs.jquery.com/Events/live#typefn) but i also can't get this to work > >> *confused* > > >> Thanks for help > >> qualle