实例代码“Ctrl+/”提示“F11/ESC”全屏 返回 格式化 恢复 运行
x
 
1
<!DOCTYPE html>
2
<html>
3
<head>
4
<script src="https://libs.baidu.com/jquery/1.10.2/jquery.min.js">
5
</script>
6
<script>
7
x=0;
8
y=0;
9
$(document).ready(function(){
10
  $("div.over").mouseout(function(){
11
    $(".over span").text(x+=1);
12
  });
13
  $("div.enter").mouseleave(function(){
14
    $(".enter span").text(y+=1);
15
  });
16
});
17
</script>
18
</head>
19
<body>
20
21
<p>The mouseout event triggers when the mouse pointer leaves any child elements as well the selected element.</p>
22
<p>The mouseleave event is only triggered when the mouse pointer leaves the selected element. </p>
23
24
<div class="over" style="background-color:lightgray;padding:20px;width:250px;float:left">
25
<h3 style="background-color:white;">Mouseout event triggered: <span></span></h3>
26
</div>
27
28
<div class="enter" style="background-color:lightgray;padding:20px;width:250px;float:right">
29
<h3 style="background-color:white;">Mouseleave event triggered: <span></span></h3>
30
</div>
31
32
</body>
33
</html>