实例代码“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
$(document).ready(function(){
8
  $("div").click(function(event){
9
    alert("Event handler 1 executed");
10
      event.stopImmediatePropagation();
11
  });
12
  $("div").click(function(event){
13
    alert("Event handler 2 executed");
14
  });
15
  $("div").click(function(event){
16
    alert("Event handler 3 executed");
17
  });
18
});
19
</script>
20
</head>
21
<body>
22
23
<div style="height:100px;width:300px;padding:10px;border:1px solid blue;background-color:lightblue;">Click on this div element.</div>
24
25
<p>The second and third click event will not be executed due to event.stopImmediatePropagation(). Try to erase this method and see what happens.
26
 
27
</body>
28
</html>