x
 
<!DOCTYPE html>
<html>
<body>
<p>本例使用 addEventListener() 方法将两个 click 事件添加到同一个按钮。但是,stopImmediatePropagation() 方法<b>停止了</b>第二个事件处理程序的执行。</p>
<p><b>注释:</b>IE8 及更早版本不支持 stopImmediatePropagation() 方法。</p>
<button id="myBtn">试一试</button>
<script>
function myFunction(event) {
  alert ("Hello World!");
  event.stopImmediatePropagation(); // Try to remove me
}
function someOtherFunction() {
  alert ("I will not get to say Hello World");
}
var x = document.getElementById("myBtn");
x.addEventListener("click", myFunction);
x.addEventListener("click", someOtherFunction);
</script>
</body>
</html>