MouseEvent 对象处理鼠标与 HTML 文档交互时发生的事件。
Event | Occurs When |
---|---|
onclick | A user clicks on an element |
oncontextmenu | A user right-clicks on an element |
ondblclick | A user double-clicks on an element |
onmousedown | A mouse button is pressed over an element |
onmouseenter | The mouse pointer moves into an element |
onmouseleave | The mouse pointer moves out of an element |
onmousemove | The mouse pointer moves over an element |
onmouseout | The mouse pointer moves out of an element |
onmouseover | The mouse pointer moves onto an element |
onmouseup | A mouse button is released over an element |
Property | Returns |
---|---|
altKey | If the ALT key is pressed |
button | Which mouse button is pressed |
buttons | Which mouse buttons were pressed |
clientX | The X coordinate of the mouse pointer (window relative) |
clientY | The Y coordinate of the mouse pointer (window relative) |
ctrlKey | If the CTRL key is pressed |
detail | The details about an event |
metaKey | If the META key is pressed |
offsetX | The X coordinate of the mouse pointer (target relative) |
offsetY | The Y coordinate of the mouse pointer (target relative) |
pageX | The X coordinate of the mouse pointer (document relative) |
pageY | The Y coordinate of the mouse pointer (document relative) |
relatedTarget | The element that triggered the mouse event |
screenX | The X coordinate of the mouse pointer (screen relative) |
screenY | The Y coordinate of the mouse pointer (screen relative) |
shiftKey | If the SHIFT key is pressed |
which | Deprecated (Avoid using it) Use the button property instead |
MouseEvent 继承了以下所有属性和方法:
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!