HOW TO DISTINGUISH BETWEEN LEFT AND RIGHT MOUSE CLICK WITH JQUERY?

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>