Yes, it's because they were re-added after you initially binded events. There are two ways around that: 1) re-bind the event to the new widget, or 2) use jQuery 1.3's new live() function: http://docs.jquery.com/Events/live#typefn Bind once, and you're good to go for future elements also.
On Feb 13, 8:31 am, Ashit Vora <a.k.v...@gmail.com> wrote: > Hi, > I 'm new to jQuery and 'm facing a some problem binding click event, a > function to an anchor tag. > > I 've an anchor tag with ID add. > > $('.add').click(function(){ > > var newElem = "<li > class='ui-state-default'>Temp Text Displayed<a > href='#' class='edit-widget-control'>edit</a> <a href='#' > class='remove-widget-control'>delete</a></li>"; > //alert(newElem); > $('#widget_window').append(newElem); > }); > > This works fine (adds new list item to widget_window which is > Unordered List Tag). > > but the below code doesnt work... :( > > $('.edit-widget-control').click(function(){ > alert('alert'); > }); > > $('.remove-widget-control').click(function(){ > alert('alert'); > }); > > 'm not sure but is it because, elements with "edit-widget-control" and > "remove-widget-control" classes are added later (on click event of > "ADD"), jQuery is unable to assign event to them. > > Can anyone help me with this issue ??? > > Thanks :)