Possible Duplicate:
Jquery: detect if middle or right mouse button is clicked, if so, do this:
How do I show alert box that says "middle mouse button clicked" when I click on text, or any dom element? I want to be able to differentiate between middle mouse and normal right click using jquery/javscript.
I did refer to this: Jquery: detect if middle or right mouse button is clicked, if so, do this:
and modified the js fiddle to this: http://jsfiddle.net/zAGLP/29/
But am seeking an alternative to "live()" function.
$(document).bind('mousedown', function(e) {
if( (e.which == 1) ) {
alert("left button");
}if( (e.which == 3) ) {
alert("right button");
}else if( (e.which == 2) ) {
alert("middle button");
}
e.preventDefault();
}).bind('contextmenu', function(e){
e.preventDefault();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With