美文网首页
阻止冒泡,默认事件

阻止冒泡,默认事件

作者: YT_Zou | 来源:发表于2017-01-13 15:20 被阅读0次

JS停止冒泡

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

JS阻止默认行为

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

相关文章

网友评论

      本文标题:阻止冒泡,默认事件

      本文链接:https://www.haomeiwen.com/subject/lqjsbttx.html