dom常用事件总结
- 鼠标事件
事件名 | 作用 |
Element.onclick | 元素被点击时,触发事件 |
Element.ondblclick | 双击时调用 |
Element.onmousedown | 鼠标按下时,触发事件(左键右键都可以) |
Element.onmouseup | 鼠松开时,触发事件 |
Element.onmouseseenter | 鼠标移上时触发 |
Element.onmouseleave | 鼠标离开时触发 |
Element.onmouseover | 鼠标移上时触发 |
Element.onmouseout | 鼠标离开时触发 |
Element.onmousemove | 鼠标移动时触发,一直移动一直触发 |
window.oncontextmenu | 鼠标右击时触发(允许右击的情况下) |
2、键盘事件
window.onkeydown | 键盘被按下 |
Element.onkeyup | 键盘按键被松开 |
Element.onkeypress | 键盘按下并且松开 |
3、表单事件
onblur | 失去焦点时,触发 |
Element.onfocusin | (即将)获取到焦点时,触发 |
Element.onfocus | 获取到焦点时,触发 |
Element.onfocusout | (失去)焦点时,触发 |
Element.oninput | 有数据输入时就会触发 |