:::: MENU ::::
Posts tagged with: left mouse click

How to detect left mouse click and right mouse click with jQuery

If you want to implement a javascript interface probably you will get to a point where you have to know witch button was pressed. The next code will detect correctly for IE, Firefox, Chrome, Opera and Safari.

/* this will append click detection to whole document
 * if you want to add this feature just on one area
 * just change the selector for the jQuery
jQuery(document).click(function(event) {
   if (jQuery.browser.msie){
      if (event.which < 2){
         alert('Left button');
   switch (event.which) {
      case 1:
         alert('Left button');
      case 2:
         alert('Middle button');
      case 3:
         alert('Right button');


Continue Reading