jQuery event.isPropagationStopped() 方法

实例

检查 event.stopPropagation() 是否被调用:

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script src="https://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
  5. <script>
  6. $(document).ready(function(){
  7. $("div").click(function(event){
  8. event.stopPropagation();
  9. alert("event.stopPropagation() 被调用: " + event.isPropagationStopped());
  10. });
  11. });
  12. </script>
  13. </head>
  14. <body>
  15. <div style="height:100px;width:300px;padding:10px;border:1px solid blue;background-color:lightblue;">点击 div 元素</div>
  16. </body>
  17. </html>

定义与用法

event.isPropagationStopped() 方法检查是否 event.stopPropagation() 被事件调用。

如果 event.stopPropagation() 方法被调用,则返回 true,否则返回 false


语法

  1. event.isPropagationStopped()
参数描述
event必填。 event 参数来自事件绑定函数

分类导航