Find out which mouse button that was pressed when a mouse event was triggered:
The button property returns a number that indicates which mouse button was pressed when a mouse event was triggered.
This property is mostly used together with the onmousedown event.
Note: This property is read-only.
The numbers in the table specify the first browser version that fully supports the property.
Property | |||||
---|---|---|---|---|---|
button | Yes | Yes | Yes | Yes | 8.0 |
Return Value: |
A Number, representing which mouse button that was pressed when the mouse event occured. Possible values:
Note: Internet Explorer 8 and earlier has different return values:
|
---|---|
DOM Version: | DOM Level 2 Events |
HTML DOM reference: MouseEvent buttons Property
HTML DOM reference: MouseEvent which Property