设置的a的class为on
如果点击了后面的标签的话,那么第一个的标签不还是亮着的吗?
如果点击了后面的标签的话,那么第一个的标签不还是亮着的吗?
2017-07-07
var a = document.getElementsByTagName("a"),
len = a.length,
i = 0;
for(i=0; i<len; i++){
a[i].index = i;
a[i].onmouseover = function(){
clearInterval(this.timer_out ); // 清除离开时的动画栈
var _this = this;
_this.timer_over = setInterval(function(){
_this.style.width = _this.offsetWidth + 8 +"px";
if (_this.offsetWidth >= 160){
_this.style.width = 160 +"px";
clearInterval(_this.timer_over );
}
},30)
}
a[i].onmouseout = function(){
clearInterval(this.timer_over ); // 清除悬浮时的动画栈
var _this = this;
_this.timer_out = setInterval(function(){
_this.style.width = _this.offsetWidth - 8 +"px";
if (_this.offsetWidth <= 120){
_this.style.width = 120 +"px";
clearInterval(_this.timer_out );
}
},30)
}
}
举报