Javascript examples for DOM:Mouse Event
The button property indicates which mouse button was pressed.
This property is read-only.
A Number, representing which mouse button that was pressed.
Possible values:
The following code shows how to find out which mouse button that was pressed:
<!DOCTYPE html> <html> <body> <div onmousedown="WhichButton(event)">Click this text</div> <h2>You pressed button: <span id="demo"></span></h2> <script> function WhichButton(event) {/* www . j a v a 2 s . c o m*/ var x = event.buttons; document.getElementById("demo").innerHTML = x; } </script> </body> </html>