JQuery - trigger events when a link is clicked

I would like to trigger an event when a link clicks, clicking on it in normal mode or opening it in a new tab (e.g. middle click, Ctrl + click, etc.)

I tried the following:

$('a').click(myfunc) Does not capture medium clicks.

$('a').mousedown(myfunc) works, but it seems to prevent linking, although my function does not call event.preventDefault .

Any ideas how to do this?

+7
javascript jquery firefox events
source share
1 answer

Try returning true from the handler function. The return cannot be interpreted by the browser as a void return and thus prevent the default action from being performed.

+6
source share

All Articles