jQuery, check witch mouse button had been pressed

The .click is great, but witch button had been pressed?

  1. $(document).click(function(e) {
  2.    if ((e.button == 0)  && (e.button == 1)){
  3.       // was the left button pressed
  4.       alert(‘clicked’);
  5.    }
  6.    if (e.button == 3){
  7.       // was the right button pressed
  8.       alert(‘click’);
  9.    }
  10. });

Tags: , , , , ,

Comments are closed.