$("#commenting").append("<span class='commentTag'>"+fill+"</span><span class='deleteTag'>x</span>") .find('.deleteTag').bind('click', function(){ // perform removal });
On Dec 18, 7:09 am, Kyle <[EMAIL PROTECTED]> wrote: > Hi, > > This is frustrating! First, because I'm having a problem I can't > solve. Second, because I can't track down the solution (though I know > I've seen it before- albeit months ago). > > After something is clicked, this code is executed: > > $("#commenting").append("<span class='commentTag'>"+fill+"</span><span > class='deleteTag'>x</span>"); > > Now, as you can probably infer from the "x" and class name for the > second span, I want to be able to click on the span deleteTag and have > it remove the element prior. However, it does not allow me to do > anything with the new class once it has been added! > > $(".deleteTag").click(function() > { > alert("Please work!"); > > }); > > If I recall correctly, I think I need to bind the new class to the > DOM. I'm just not sure how, even after reading the documentation. > > Thanks for any help you can provide! > > Kyle