X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY ANGULAR BOOTSTRAP XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

button Event Attribute

Event Object Reference Event Object

Definition and Usage

The button event attribute returns a number that indicates which mouse button was clicked when an event was triggered.

Syntax

event.button=0|1|2

Parameter Description
0 Specifies the left mouse-button
1 Specifies the middle mouse-button
2 Specifies the right mouse-button

Note: Internet Explorer 8 and earlier has different parameters:

Parameter Description
1 Specifies the left mouse-button (IE8 and earlier)
4 Specifies the middle mouse-button (IE8 and earlier)
2 Specifies the right mouse-button


Tips and Notes

Note: For a left-hand configured mouse, the parameter values are reversed.


Examples

Try it Yourself - Examples

Alert which mouse button that was pressed
Alert which mouse button the user pressed.


Event Object Reference Event Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook