求教育 這里的取消冒泡應(yīng)該怎么寫 這樣寫出來的不管用哇
window.onload=function(){ ????var?aLi=document.getElementsByTagName('li'); ????for(var?i=0;?i<aLi.length;?i++){ ????????aLi[i].onmouseover=function(event){???? ????????var?event?=?event?||?window.event ????????if(event.stopPropagation){ ????????????event.stopPropagation();} ????????else{event.cancelBubble?=?true;}; ????????var?aNav?=?this.getElementsByTagName('ul');???? ????????var?animate?=?setInterval(function(){ ????????????aNav[0].style.height?=?aNav[0].offsetHeight?+?5?+?"px"; ????????????if(aNav[0].offsetHeight?>=?120){ ????????????clearInterval(animate); ????????????}???? ????????????},10); ???? ????????} ???????? ????????aLi[i].onmouseout=function(){ ????????var?aNav?=?this.getElementsByTagName("ul")[0]; ????????aNav.style.height?=?0; ????????} ???????? ???????? ????} } </script>
求教育。這樣并不管用哇
2017-03-19
//鼠標(biāo)經(jīng)過一級菜單,二級菜單動畫下拉顯示出來
? ? ? ? aLi[i].onmouseover=function(){
? ? ? ? ? var oSubNav=this.getElementsByTagName('ul')[0];
? ? ? ? ? if(oSubNav){
? ? ? ? ? var This=oSubNav;
? ? ? ? ? clearInterval(This.time);
? ? ? ? ? This.time=setInterval(function(){
? ? ? ? ? ? ? ? ? This.style.height=This.offsetHeight+16+"px";
? ? ? ? ? ? ? ? ? if(This.offsetHeight>=120)
? ? ? ? ? ? ? ? ? clearInterval(This.time);
? ? ? ? ? ? ? },30)
? ? ? ? ? }
? ? ? ? }
? ? ? ? //鼠標(biāo)離開菜單,二級菜單動畫收縮起來。 ? ?
? ? ? ? aLi[i].onmouseout=function(){
? ? ? ? ? ? var oSubNav=this.getElementsByTagName('ul')[0];
? ? ? ? ? ? oSubNav.style.height='0px'; ? ? ?
? ? ? }
2017-03-02
var?event?=?event?||?window.event少了個分號
2016-12-27
主流瀏覽器如:chrome等是event.stoppropagation()方法;,IE中是cancleBubble()屬性。