The way the DOM + JS works, you can't "hijack" the order of execution when mixing/matching library (jquery) event handling and inline script event handling. Two things come to mind:
- Use a mousedown/up event, which will fire before the click event.
- Modify/manipulate the DOM with jquery after load so you have more control.
Pseudo Example of option #2:
$(function()
{
$('a[onclick]').click(function() { /* your normal on click here */ });
// now modify the DOM to convert the onclick attr into a function call
$('a[onclick]').each(function()
{
var clickFunction = $(this).attr('onclick');
// remove the attr
$(this).attr('onclick', '');
// might be a better way than calling eval on the inline function, but this serves its purpose for the demo
$(this).click(function() { eval(clickFunction); });
});
});
So in the above example, I remove the onclick attr and conver it to a jquery click event handler, and I do it second, not first, so it happens after my newly inserted pre-onclick function.