返回值:Boolean event.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>