$('div').bind('click', function(){
alert('clicked');
});
$('div').bind('rightclick', function(){
alert('right mouse button is pressed');
});
I want to distinguish between right and left clicks like this, but what do I do...
javascript jquery
Use event.which for jQuery
$('#element').mousedown(function(event) {
switch (event.which) {
case 1:
alert('Left Mouse button pressed.');
break;
case 2:
alert('Middle Mouse button pressed.');
break;
case 3:
alert('Right Mouse button pressed.');
break;
default:
alert('You have a strange Mouse!');
}
});
You can do it like this.
© 2024 OneMinuteCode. All rights reserved.