Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

button Event Attribute

button Event Attribute

Event Object Reference Event Object


Definition and Usage

The button event attribute can return an integer that indicates which mouse button was clicked when the event was triggered.

Syntax

event.button=0|1|2

Parameters 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 IE versions have different parameters:

Parameters Description
1 Specifies the left mouse button. (IE8 and earlier IE versions)
4 Specifies the middle mouse button. (IE8 and earlier IE versions)
2 Specifies the right mouse button.

Tips and Notes

Note: For left-handed mouse configurations, the above parameters are reversed.


More examples

Alerts which mouse button was clicked
Alerts which mouse button was clicked.


Event Object Reference Event Object