Course recommendation :
MouseEvent which attribute
Definition and usage
which attribute returns a number indicating which mouse button was pressed when the mouse event was triggered.
Note :This attribute is mainly used with the onmousedown event. The value returned by this attribute is equal to button attribute
Note :The return value is incremented by one.
This property is read-only.
Example
Find out which mouse button was pressed when the mouse event was triggered:
Try it yourself
Syntax
Technical details
Return value : |
Numeric values representing the mouse button pressed when the mouse event occurs. Possible values :
Note :For a left-handed mouse configuration, the return value is reversed. |
---|---|
DOM version : | DOM Level 2 Events |
Compatibilité des navigateurs
Les numéros dans le tableau indiquent la version du navigateur qui prend en charge cette propriété pour la première fois.
Propriétés | Chrome | IE | Firefox | Safari | Opera |
---|---|---|---|---|---|
which | 1.0 | 9.0 | 1.0 | 1.0 | 5.0 |
Pages associées
Manuel de référence DOM HTML :Propriété button de MouseEvent
Manuel de référence DOM HTML :Propriété buttons de MouseEvent