I have small application:
http://jsfiddle.net/Bwdf6/4/
But with click on delete, tags that created after page load doesnt remove.
Is there any way to remove tags that created after page load?
Thanks in advance
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use
live()– Working Demo.As you’re creating your elements dynamically, using
click()isn’t enough – that only assigns a click handler to all the.spelements that exist at the timeclick()is called.live(), on the other hand, is used to:So any new elements added dynamically with a class of
spwill have that handler attached to them.EDIT: Actually, as a couple of people have pointed out, while
live()will do what you need, the most efficient function to use in this instance would bedelegate(), which is used to:I won’t steal glory by posting a code sample – see @Mark’s answer, which should be accepted instead of mine.