I want to attach a click event handler to each and every (Button, Anchor, Select) on all pages in my application, and that handler should run before the already attached ha
This should rearrange your click handlers.
$(document).ready(function() {
$("input[type=button]").each(function() {
// your button
var btn = $(this);
var clickhandler = this.onclick;
this.onclick = null;
// new click handler
btn.click(function() {
alert('Prepended Handler');
});
btn.click(clickhandler);
});
});
function f2() {
alert('Handler declared in HTML');
}