How do you obtain the clicked mouse button using jQuery?
$(\'div\').bind(\'click\', function(){
alert(\'clicked\');
});
this is trigger
There are a lot of very good answers, but I just want to touch on one major difference between IE9 and IE < 9 when using event.button.
According to the old Microsoft specification for event.button the codes differ from the ones used by W3C. W3C considers only 3 cases:
event.button === 1event.button === 3event.button === 2In older Internet Explorers however Microsoft are flipping a bit for the pressed button and there are 8 cases:
event.button === 0 or 000event.button === 1 or 001event.button === 2 or 010event.button === 3 or 011event.button === 4 or 100event.button === 5 or 101event.button === 6 or 110event.button === 7 or 111Despite the fact that this is theoretically how it should work, no Internet Explorer has ever supported the cases of two or three buttons simultaneously pressed. I am mentioning it because the W3C standard cannot even theoretically support this.