与人类鼠标点击相关的所有事件是什么?
What are all the events associated with a human mouse click?
当用户单击 HTML 元素时,似乎有许多 JavaScript 事件 除了 只是 "click" 被触发。例如,点击 input/text 元素也会触发 focus、mousedown、mouseup[=19= 等事件],等等...
本质上,当人点击一个元素时,会触发哪些事件? (除了点击!)
检查 w3 中的这一点:
应该是您要找的。另外 MDN 对它们有很好的概述
对于具体的按钮点击,会有:
mousedown
mouseup
click
如果鼠标在你查看的那段时间进入了一个新的元素你可能还会看到:
mousemove
mouseover
mouseenter
mouseleave (on other element)
mouseout (on other element)
如果焦点根据点击发生变化:
focusout (on some other element)
blur (on some other element)
focusin
focus
您可以在这个记录所有事件的 jsFiddle 中看到准确的事件序列:https://jsfiddle.net/jfriend00/r9c7n5j2/
如果焦点在别处并且您点击输入标签,您将看到这一系列事件(为清楚起见,只显示了一个 mousemove
事件,但可能会有很多):
mouseover
mouseenter
mousemove
mousedown
focus
focusin
mouseup
click
注意:Firefox 尚不支持 focusin
。
当用户单击 HTML 元素时,似乎有许多 JavaScript 事件 除了 只是 "click" 被触发。例如,点击 input/text 元素也会触发 focus、mousedown、mouseup[=19= 等事件],等等...
本质上,当人点击一个元素时,会触发哪些事件? (除了点击!)
检查 w3 中的这一点:
应该是您要找的。另外 MDN 对它们有很好的概述
对于具体的按钮点击,会有:
mousedown
mouseup
click
如果鼠标在你查看的那段时间进入了一个新的元素你可能还会看到:
mousemove
mouseover
mouseenter
mouseleave (on other element)
mouseout (on other element)
如果焦点根据点击发生变化:
focusout (on some other element)
blur (on some other element)
focusin
focus
您可以在这个记录所有事件的 jsFiddle 中看到准确的事件序列:https://jsfiddle.net/jfriend00/r9c7n5j2/
如果焦点在别处并且您点击输入标签,您将看到这一系列事件(为清楚起见,只显示了一个 mousemove
事件,但可能会有很多):
mouseover
mouseenter
mousemove
mousedown
focus
focusin
mouseup
click
注意:Firefox 尚不支持 focusin
。