<script>
$("#test_img").click(function() {
alert("Hello");
});
</script>
But it doesn’t matter what mouse button I’m pressing – right or left. I see absolutely the same result. I want alert to be shown only on left mouse button click.
Thank you and sorry; I’m little new to javascript.
Thank you.
You can evaluate the
event.whichattribute to determine which button has been pressed.Furthermore, to safely detect a mousebutton, you cannot use the
click-event! Usemousedownormouseupinstead.