js 阻止冒泡事件和默认事件
程序员文章站
2022-10-05 08:35:56
阻止事件冒泡 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; }