how to use jquery get the event?
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.
精彩评论