MouseEvent which attribute
Definition and usage
The which attribute returns a number indicating which mouse button was pressed when the mouse event was triggered.
This attribute is mainly used with the onmousedown event.
Notes:The value returned by this attribute is equal to button attribute The return value is incremented by one.
Notes:This property is read-only.
Example
Find out which mouse button was pressed when the mouse event was triggered:
alert("You pressed button: " + event.which)
Syntax
event.which
Technical details
Return value: |
Numeric values representing the mouse button pressed when a mouse event occurs. Possible values:
Notes:For mice configured for left-handed use, the return value is reversed. |
---|---|
DOM Version: | DOM Level 2 Events |
浏览器支持
表中的数字注明了完全支持该属性的首个浏览器版本。
Muarama | Chrome | IE | Firefox | Safari | Opera |
---|---|---|---|---|---|
which | 1.0 | 9.0 | 1.0 | 1.0 | 5.0 |
Vipindi vya vitengo vya
Mwongozo wa HTML DOM:Mwili wa button katika Mshahara wa MouseEvent
Mwongozo wa HTML DOM:Mwili wa buttons katika Mshahara wa MouseEvent