十三、JavaScript事件
1.事件_事件流
一、什么是事件:事情的起因
二、事件流
1》事件冒泡:从内到外(先触发里面的,再触发外部)
2》事件捕获:从外到内
测验:
<div id="dv1" style="background: red;width: 400px;height: 400px;">
<div id="dv2" style="background: wheat;width: 200px;height: 200px;"></div>
</div>
var dv1 = document.getElementById("dv1");
var dv2 = document.getElementById("dv2");
dv1.onclick = function(){
alert(1);
}
dv2.onclick = function(){
alert(2);
}
2.事件_鼠标类事件
1》onclick ==》单击事件
2》ondblclick=》双击事件
3》oncontextmenu ===》右击事件
4》onmouseover ====》鼠标移入(穿过)
5》onmouseout ====》鼠标移出
6》onmousemove ===》鼠标移入(一直会执行的代码)
7》onmousedown ====》鼠标按下
8》onmouseup ===》鼠标释放(松开)
var box=document.