Detect left mouse button click with jQuery

This script below will detect left mouse click and pop up an alert when you left click on the link “Click me”.

Code:

<script>
$(function(){
$(“#click-me”).live(‘click’, function(e) {
if( e.button == 0 ) { // Clicked with left mouse button
alert(‘You clicked with left mouse button’);
}
});
});
</script>

<a id=”click-me”>Click me</a>