the code is like this:
<a onclick="ajaxClick()">aaa</a>
now i want to get the event in function ajaxClick(){ //? }
since the code is loaded from ajax request, so there is noway to use bind().
is there any jquery API could do this? thanks.
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.
Try using
jQuery.live()to bind to existing and future elements:Remove the
onClick="ajaxClick()"and use the above code instead. If you’re using jQuery it’s better to use it to bind to events instead of mixing up techniques. jQuery also normalizes event-handling across browsers, so it’s easier to deal with events.