event.isPropagationStopped()
返回: Boolean
event.isPropagationStopped()
描述:返回event.stopPropagation()
是否已经在该事件对象上调用过了。
加入于: 1.3
event.isPropagationStopped()该方法不接受任何参数
W3C DOM Level 3 规范文档中描述了该事件方法。
示例
检查event.stopPropagation()
是否已经被调用了。
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>event.isPropagationStopped demo</title> <script src="https://code.jquery.com/jquery-1.10.2.js"></script> </head> <body> <button>click me</button> <div id="stop-log"></div> <script> function propStopped( event ) { var msg = ""; if ( event.isPropagationStopped() ) { msg = "called"; } else { msg = "not called"; } $( "#stop-log" ).append( "<div>" + msg + "</div>" ); } $( "button" ).click(function(event) { propStopped( event ); event.stopPropagation(); propStopped( event ); }); </script> </body> </html>
演示结果