hi, 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.
hi, 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.
Try using jQuery.live()
to bind to existing and future elements:
var ajaxClick = function() {
//your handler
};
jQuery("a").live("click", ajaxClick);
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.