what i want to realize is : when I right click a link , it also jump to another page like left click. how to do it? thanks very much.
There is a plugin that will handle a lot of this for you: http://abeautifulsite.net/blog/2008/05/jquery-right-click-plugin/
Or if you wanted to roll your own:
Check out the docs for event.which: http://api.jquery.com/event.which/
You can detect which mouse button was clicked:
$('.clicky').mousedown(function(event) { switch (event.which) { case 1: alert('Left mouse button pressed'); break; case 2: alert('Middle mouse button pressed'); break; case 3: alert('Right mouse button pressed'); // you would want to prevent default behavior and trigger a click event.preventDefault(); $(this).trigger('click'); break; default: alert('You have a strange mouse'); } });
1.4m articles
1.4m replys
5 comments
57.0k users