jQuery event.isPropagationStopped() 方法
实例
检查 event.stopPropagation() 是否被调用:
<!DOCTYPE html><html><head><script src="https://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script><script>$(document).ready(function(){$("div").click(function(event){event.stopPropagation();alert("event.stopPropagation() 被调用: " + event.isPropagationStopped());});});</script></head><body><div style="height:100px;width:300px;padding:10px;border:1px solid blue;background-color:lightblue;">点击 div 元素</div></body></html>
定义与用法
event.isPropagationStopped() 方法检查是否 event.stopPropagation() 被事件调用。
如果 event.stopPropagation() 方法被调用,则返回 true,否则返回 false。
语法
event.isPropagationStopped()
| 参数 | 描述 |
|---|---|
| event | 必填。 event 参数来自事件绑定函数 |