Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery - Triggering Events from Clicking on a Link Issue

I'd like to trigger an event when a link is clicked both by clicking on it normally or by opening it in a new tab (e.g., middle click, ctrl + click, etc)

I've tried the following so far:

$('a').click(myfunc) Doesn't capture middle clicks.

$('a').mousedown(myfunc) works, but it seems to be preventing the link from being followed even though my function doesn't call event.preventDefault.

Any ideas how to do this then?

like image 273
Greg Avatar asked Sep 29 '08 01:09

Greg


1 Answers

Try returning true from your handler function. Returning nothing can be interpreted by the browser as a void return and thus prevent the default action from being carried out.

like image 131
levik Avatar answered Oct 20 '22 04:10

levik