javascript - jQuery - Triggering Events from Clicking on a Link Issue - Stack Overflow

I'd like to trigger an event when a link is clicked both by clicking on it normally or by opening

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?

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?

Share Improve this question edited Sep 13, 2015 at 9:29 Kristijan Iliev 4,99710 gold badges30 silver badges51 bronze badges asked Sep 29, 2008 at 1:59 GregGreg 47.2k91 gold badges237 silver badges298 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745225250a4617429.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信