jQuery dropped the standard button attribute in favor of which, which is a bit puzzling.
which is introduced by Firefox and is not supported by IE. The original intention of which is to obtain the key value (keyCode) of the keyboard.
Which in jQuery can be the key value of the keyboard or the key value of the mouse.
That is, which can be used when determining which key of the keyboard the user pressed, and which can also be used when determining which key of the mouse the user pressed. It serves two purposes.
Source code
IE6/7/8 | IE9 | Firefox4 | Chrome12 | Safari | Opera | |
点击左键 | 0 | 1 | 1 | 1 | 1(不停弹出alert) | 1 |
点击中键 | 不响应 | 2 | 2 | 2 | 2(不停弹出alert) | 不响应 |
点击右键 | 仅弹出右键菜单 | 仅弹出右键菜单 | 3,弹出右键菜单 | 仅弹出右键菜单 | 仅弹出右键菜单 | 仅弹出右键菜单 |
You can see that using the click event does not correspond to the 1, 2, and 3 values for the left, middle, and right keys as jQuery imagined. It is inconsistent in each browser, and the right-click cannot be obtained at all, and alerts keep popping up in Safari.
Therefore, mousedown / mouseup events should be used to achieve jQuery's vision. jQuery's comments are misleading.
In addition, even if the mousedown / mouseup events are used, the value of the middle button cannot be obtained in Opera. Opera's disgusting practices make jQuery powerless.