event.isImmediatePropagationStopped()
返回: Boolean
event.isImmediatePropagationStopped()
描述:返回event.stopImmediatePropagation()
是否已经在该事件对象上调用过了。
加入于: 1.3
event.isImmediatePropagationStopped()该方法不接受任何参数
DOM level 3中引入了该属性。
示例
检查event.stopImmediatePropagation()
是否已经被调用过了。
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>event.isImmediatePropagationStopped 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 immediatePropStopped( event ) { var msg = ""; if ( event.isImmediatePropagationStopped() ) { msg = "called"; } else { msg = "not called"; } $( "#stop-log" ).append( "<div>" + msg + "</div>" ); } $( "button" ).click(function( event ) { immediatePropStopped( event ); event.stopImmediatePropagation(); immediatePropStopped( event ); }); </script> </body> </html>
演示结果