s
当前位置主页 > jquery文档 > eve.isImmediatePropagationStopped()

eve.isImmediatePropagationStopped() | jQuery API

2015-01-12 

返回值:Booleanevent.isImmediatePropagationStopped()

V1.3概述

根据事件对象中是否调用过 event.stopImmediatePropagation() 方法来返回一个布尔值。

示例

描述:

检测 event.stopImmediatePropagation() 是否被调用过。

代码:
<!DOCTYPE html>
  <html>
  <head>
    <script src="http://code.jquery.com/jquery-latest.min.js"></script>
  </head>
  <body>
    <button>click me</button>
    <div id="stop-log"></div>
    <script>
   function immediatePropStopped(e) {
    var msg = "";
    if ( e.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>
Previous:
上一篇:eve.delegateTarget
Next:
下一篇:eve.isPropagationStopped()
返回顶部