阻止默认事件和事件冒泡

阻止默认事件

常用兼容方法:

function(e){
	e = e || window.event;
	e.preventDefault?e.preventDefault():e.returnValue=false;
}

阻止事件冒泡

function(e){
	e = e || window.event;
	e.stopPropagation?e.stopPropagation():e.cancelBubble = true;
}

猜你喜欢

转载自blog.csdn.net/weixin_43444623/article/details/84669946