<script>
//dom加载完才执行以下代码
window.onload=function(){
//取得a标签数据
var atag = document.getElementsByTagName("a");
for(var i=0; i< atag.length;i++) {
/**鼠标移入**/
atag[i].onmouseover=function(){
//先清空
clearInterval(this.time);
//获得当前的this对象
var thisPara = this;
thisPara.time=setInterval(function(){
thisPara.style.width = thisPara.offsetWidth + 8 + "px";
if(thisPara.offsetWidth > 120){
clearInterval(thisPara.time);
}
},30);
};
/**鼠标移出**/
atag[i].onmouseout=function(){
//先清空
clearInterval(this.time);
var thisPara = this;
setInterval(function(){
thisPara.style.width = thisPara.offsetWidth - 8 +"px";
if(thisPara.offsetWidth < 80){
thisPara.style.width = "80px";
clearInterval(thisPara.time);
}
},30)
};
}
}
</script>