首页 > 代码库 > js实现水平伸缩菜单

js实现水平伸缩菜单

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)        }    }}

 

js实现水平伸缩菜单