How do you obtain the clicked mouse button using jQuery?
$('div').bind('click', function(){
alert('clicked');
});
this is triggered by both right and left click, what is the way of being able to catch right mouse click? I'd be happy if something like below exists:
$('div').bind('rightclick', function(){
alert('right mouse button is pressed');
});
Best Answer
As of jQuery version 1.1.3,
event.which
normalizesevent.keyCode
andevent.charCode
so you don't have to worry about browser compatibility issues. Documentation onevent.which
event.which
will give 1, 2 or 3 for left, middle and right mouse buttons respectively so: