Add a click event that happens after inline click event?
Using jQuery, I want to add a click event to a search button that happens after the event that is already tied to that button in the HTML (the other click event is in the tag's onclick event, it is NOT added by javascript).
I've tried using .click(function() {..开发者_如何学运维.});
but that event will fire before the inline onclick event already on the button. How can I run my click event after the first one has completed?
One thing you can do is grab the inline events when the page loads and evaluate them before your custom click event code.
Something like this:
var events = $('#someAnchor').attr('onclick');
$('#someAnchor').removeAttr('onclick');
$('#someAnchor').click(function(){
eval(events);
alert("We came second");
})
Here's a quick example: http://jsfiddle.net/vkVuP/
精彩评论