//事件冒泡
window.onload=function()
{
   var oBtn=document.getElementById("btn1");
     var ev=event?event:window.event;
   oBtn.onclick=function()
   {
    
      alert("btn1");
      ev.cancelBubble=true; //阻止事件冒泡 后面不会弹出“document"
   }
   document.onclick=function()
   {
      alert("document");
   }
}

 

相关文章:

  • 2021-11-01
  • 2021-07-22
  • 2021-11-19
  • 2021-12-08
  • 2021-09-09
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-02
  • 2021-07-31
  • 2022-12-23
  • 2021-07-03
  • 2021-06-04
相关资源
相似解决方案