鼠标事件:
单机事件:onclick
双击事件:ondblClick
鼠标移入 onmouseover
鼠标移出 onmouseout (会触发事件冒泡)
鼠标进入 onmouseenter
鼠标离开 onmouseleave (触发捕获)
鼠标移动 onmousemove
获取焦点事件: onfocus
失去焦点 onblur
(form表单)键盘事件:
按下 onkeydown
抬起 onkeyup
浏览器事件:
加载完成onlaod
浏览器滚动 onscroll
以下是测试代码
var child = document.getElementById('child')
var parent = document.getElementById('parent')
// parent.onclick = function () {
// console.log('parent');
// }
// child.onclick = function () {
// console.log('child');
// }
// parent.onmouseover = function () {
// console.log('parent');
// }
// child.onmouseover = function () {
// console.log('child');
// }
child.onmouseenter = function () {
console.log('child');
}
parent.onmouseenter = function () {
console.log('parent');
}
// box.ondblclick = function () {
// console.log('测试');
// }
// box.onmousemove = function () {
// console.log('测试1');
// }
var n = 0
window.onscroll = function () {
n++
console.log(n);
}