目录

HTML DOM MouseEvent

❮ DOM 事件 ❮ 事件对象


鼠标事件对象

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 继承了以下所有属性和方法:

Ui事件

事件对象


❮ DOM 事件 ❮ 事件对象