事件冒泡
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
div{
width: 300px;
height: 300px;
border: 1px solid #000000;
float: left;
margin: 10px 20px;
}
div p{
background-color: gray;
color: #FFFFFF;
text-align: center;
height: 50px;
line-height: 50px;
}
</style>
<script>
var a = 0;
var b = 0;
var c = 0;
var d = 0;
var e = 0;
function myMove(){
a++;
var font = document.getElementById("a");
font.innerHTML = a;
}
function myOver(){
b++;
var font = document.getElementById("b");
font.innerHTML = b;
}
function myOut(){
c++;
var font = document.getElementById("c");
font.innerHTML = c;
}
function myEnter(){
d++;
var font = document.getElementById("d");
font.innerHTML = d;
}
function myLeave(){
e++;
var font = document.getElementById("e");
font.innerHTML = e;
}
</script>
</head>
<body>
<div onmousemove="myMove()">
<font id="a">0</font>
<p>鼠标移动事件onmousemove</p>
</div>
<div onmouseover="myOver()">
<font id="b" style="border: 1px solid #000000;">0</font>
<p>鼠标移入事件onmouseover</p>
</div>
<div onmouseout="myOut()">
<font id="c">0</font>
<p>鼠标移出事件onmouseout</p>
</div>
<div onmouseenter="myEnter()">
<font id="d">0</font>
<p>鼠标移入事件onmouseenter</p>
</div>
<div onmouseleave="myLeave()">
<font id="e">0</font>
<p>鼠标移出事件onmouseleave</p>
</div>
</body>
</html>