我想知道无限延长的原理
window.onload=function(){ var aA=document.getElementsByTagName('a'); for(var i=0; i<aA.length; i++){ aA[i].onmouseover=function(){ var This=this; clearInterval(This.time); 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) } } }
像我上面把onmouseout中的clearInterval(this.time);注释掉,其余不变,为什么当我的鼠标划过一个标签并迅速离开,该标签就会无限延长。当标签延长到160px不是会触发onmouseover下的清除计时器吗?