请问为什么我这样写鼠标滑到二级菜单,他就给我缩回去了,不都是变量名吗?
动画菜单* { margin: 0; padding: 0; font-size: 14px; }a { color: #333; text-decoration: none }ul{ list-style: none; }.nav {height: 30px; border-bottom: 5px solid #F60; margin-left:50px; width:600px;}.nav li { float: left; position:relative; height:30px; width:120px }.nav li a { display: block; height: 30px; text-align: center; line-height: 30px; width:120px; background: #efefef; margin-left: 1px; }.subNav{ position:absolute; top:30px; left:0; width:120px; height:0; overflow:hidden}.subNav li a{ background:#ddd }.subNav li a:hover{ background:#efefef}<script>window.onload=function(){ var aLi=document.getElementsByTagName('li'); for(var i=0; i=120){ clearInterval(lala); } },30) } //鼠标离开菜单,二级菜单动画收缩起来。 aLi.onmouseout=function(){ var This=this.getElementsByTagName('ul')[0]; clearInterval(lala) var lala=setInterval(function(){ This.style.height=This.offsetHeight-16+"px"; if(This.offsetHeight=120){</p> clearInterval(This.time);
}
},30)
}
//鼠标离开菜单,二级菜单动画收缩起来。
aLi.onmouseout=function(){
var This=this.getElementsByTagName('ul')[0];
clearInterval(This.time)
This.time=setInterval(function(){
This.style.height=This.offsetHeight-16+"px";
if(This.offsetHeight |
免责声明:本内容仅代表回答会员见解不代表天盟观点,请谨慎对待。
版权声明:作者保留权利,不代表天盟立场。
|
|
|
|
你要搞清楚对象和元素的区别。
在this.time 里你的this是元素,等于在这个元素里面加上一个time
可以理解为
而lala是一个var出来的变量
这个变量装了setinterval这个定时器,可以理解为lala就是这个定时器本身。
这能一样吗?
如果你是从一个对象上扩展出来的time装入setinterval就不会出错。 |
|
|
|
|