js 阻止冒泡事件

js  阻止冒泡事件

前段时间在做项目的时候写js事件时,遇到了个问题和阻止冒泡事件有关,所以就用下面代码解决的

function stop(e){
 //e.stopPropagation();
  var evt = e|| window.event;
     //IE用cancelBubble=true来阻止而FF下需要用stopPropagation方法
     evt.stopPropagation ?evt.stopPropagation() : (evt.cancelBubble=true);
 }

 

 

猜你喜欢

转载自blog.csdn.net/man8023man/article/details/8986910