非标
此特征是非标准的,且不在标准轨道中。不要在面向 Web 的生产站点中使用它:它不适用于每个用户。实现之间可能存在大的不兼容性,且行为将来可能改变。

MouseEvent.which read-only property indicates which button was pressed on the mouse to trigger the event. The standard alternatives to this property are MouseEvent.button and MouseEvent.buttons .

句法

var buttonPressed = instanceOfMouseEvent.which
					

返回值

A number representing a given button:

  • 0 : No button
  • 1 : Left button
  • 2 : Middle button (if present)
  • 3 : Right button

For a mouse configured for left-handed use, the button actions are reversed. In this case, the values are read from right to left.

规范

This is not part of any specification.

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
which 非标 Chrome 1 Edge 12 Firefox 1
1
On mousemove events, the which property is incorrectly always set to 1 .
IE 9 Opera 10.6 Safari 3.1 WebView Android Yes Chrome Android Yes Firefox Android 4
4
On mousemove events, the which property is incorrectly always set to 1 .
Opera Android 11 Safari iOS Yes Samsung Internet Android Yes

图例

完整支持

完整支持

非标。预期跨浏览器支持较差。

非标。预期跨浏览器支持较差。

见实现注意事项。

另请参阅

元数据

  • 最后修改: