js 阻止冒泡事件和默认事件
程序员文章站
2022-05-18 23:10:04
阻止事件冒泡 window.enent ? window.enent.cancelBubble = true : e.stopPropagation() function stopBubble(event){ if(window.event){//兼容IE window.event.cancelBu... ......
阻止事件冒泡 window.enent ? window.enent.cancelbubble = true : e.stoppropagation() function stopbubble(event){ if(window.event){//兼容ie window.event.cancelbubble=true; }else{ event.stoppropagation(); }
阻止默认事件 window.event? window.event.returnvalue=false : event.preventdefault(): return false
function stopdefaultevent(event){ if(window.event){//兼容ie window.event.returnvalue=false; }else{ event.preventdefault() } return false; }
上一篇: 你气任你气我打我游戏