How to distinguish between left and right mouse click with jQuery?
///HTML
<div id=”right”>Check Which Mouse Click You have Clicked
THIS IS A TEST FOR MOUSE CLICK!</div>
//JavaScript Code
$(“div”).mousedown(function(e) {
if (e.which===1)
{
alert(“left”)
}
else if (e.which ===3) {
alert(‘right mouse button is pressed’);
}
});
There are eight cases for pressed button. Among them bit 001 (1) is for left click event and bits 011(3) is for right click.