Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery alert when middle mouse button clicked? [duplicate]

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.

like image 360
Teivere Avatar asked Apr 29 '11 15:04

Teivere


1 Answers

$(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();
});
like image 151
Mario Avatar answered Nov 06 '22 01:11

Mario