Check which mouse button was clicked - Javascript DOM Event

Javascript examples for DOM Event:onmousedown

Description

Check which mouse button was clicked

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<div onmousedown="WhichButton(event)">Click this text
</div>/*from  w w  w.  ja va  2  s .c o  m*/

<script>
function WhichButton(event) {
    console.log("You pressed button: " + event.button)
}
</script>

</body>
</html>

Related Tutorials