鼠标直接在标题中来回切换就会抖动,怎么解决呢?
var aA=document.getElementsByTagName('a');
for(var i=0;i<aA.length;i++){
aA[i].onmouseover=function(){
clearInterval(this.time);
var This=this;
This.time=setInterval(function(){
This.style.width=This.offsetWidth+8+"px";
if(This.offsetWidth>=160){
clearInterval(This.time);
}
},30)
}
aA[i].onmouseout=function(){
clearInterval(this.time);
var This=this;
This.time=setInterval(function(){
This.style.width=This.offsetWidth-8+"px";
if(This.offsetWidth<=120){
This.style.width="120px";
clearInterval(This.time);
}
},30)
}
}