Document 事件完整分类(修订版)
一、文档加载与卸载事件(5个)
DOMContentLoaded
readystatechange
load
beforeunload
unload
二、鼠标事件(13个)
click
dblclick
mousedown
mouseup
mousemove
mouseover
mouseout
mouseenter
mouseleave
contextmenu
wheel
selectstart
select(当用户在
<input>或<textarea>中选择文本时触发)
三、键盘事件(3个)
keydown
keyup
keypress
四、焦点事件(4个)
focus
blur
focusin
focusout
五、表单事件(6个)
input
change
submit
reset
invalid
select(与鼠标事件中的select是同一个事件,因作用域不同可归入此类)
六、剪贴板事件(4个)
copy
cut
paste
beforecopy
七、视图与滚动事件(3个)
scroll
resize
wheel(已在鼠标事件中列出)
八、拖拽事件(7个)
drag
dragstart
dragend
dragenter
dragleave
dragover
drop
九、触摸事件(5个)
touchstart
touchmove
touchend
touchcancel
gesturestart(非标准)
十、指针事件(10个)
pointerdown
pointermove
pointerup
pointercancel
pointerover
pointerout
pointerenter
pointerleave
gotpointercapture
lostpointercapture
十一、动画与过渡事件(6个)
animationstart
animationend
animationiteration
transitionstart
transitionend
transitioncancel
十二、网络与连接事件(2个)
online
offline
十三、页面可见性与全屏事件(3个)
visibilitychange
fullscreenchange
fullscreenerror
十四、文档选区事件(1个)
selectionchange
十五、安全策略事件(1个)
securitypolicyviolation
十六、剪贴板事件补充(1个)
beforecut
十七、非标准或已废弃事件(部分)
beforeprint
afterprint
abort
error
search(用于input type="search")
关于 select 事件的说明
select 事件有两个主要应用场景:
在
<input>和<textarea>上:当用户选择文本时触发在
document上:也可以监听到文本选择,但通常推荐使用更专门的selectionchange事件
示例:
document.addEventListener('select', function(event) {
console.log('文本被选中');
// 注意:document上的select事件支持度有限,更常用的是针对具体输入元素的select事件});总计:约79个事件(已包含select事件)