HOW TO DISTINGUISH BETWEEN LEFT AND RIGHT MOUSE CLICK WITH JQUERY?

If you bind 'contextmenu' event that only capture right clicks, like:

// FROM https://api.jquery.com/contextmenu/
$( "#target" ).contextmenu(function() {
  alert( "Handler for .contextmenu() called." );
});

Or you can listen to mouse down, like this:

$('#element').mousedown(function(event) {
    var button = event.which || event.button;
    switch (button) {
        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!');
    }
});

Or you can use some plugins for context menus if that what you want:
https://plugins.jquery.com/tag/right-click-menu/

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.