Skip to main content
Sep 01, 2013

At the first place we need to assume that our HTML code contains the code:

<div id="buttondiv">Button</div>
<br/>
<p>Press Mouse Button over the "Button" text above</p>

Next step is to add jQuery code to check which mouse button is clicked:

$(document).ready(function() {
    $('#buttondiv').mousedown(function(event){
        if(event.button==1){
            $('p').text('Left button is clicked.');
        } else {
            $('p').text('Right button is clicked');
        }
    });
});