I know that we could use “live” method for such purposes as stated here. But now “live” method is removed in jQuery 1.9.0. So how should I bind some event (for example, “click”) for elements loaded by Ajax?
Share
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.
There is
.on()for binding events:usage:
This will alert the id of the elem which is loaded through ajax.
You have to delegate the events to the existing parent, like this:
here
.classofdivis a div which has got content loaded from the ajax function and when you click theelemwith class name.loaded-via-ajaxthis will get the event and finally alerts its id (if that elem has an id)