<script type="text/javascript"> window.onload = function(){ var ali = document.getElementsByClassName('li'); for(var i = 0; i < ali.length; i++){ ali[i].onmouseover = function(){ startMove(this,400); } ali[i].onmouseout = function(){ startMove(this,200); } } var timer = null; function startMove(obj,tiger){ clearInterval(timer); timer = setInterval(function(){ var speed = (tiger - obj.offsetWidth)/8; speed = speed > 0?Math.ceil(speed):Math.floor(speed); if(obj.offsetWidth == tiger){ clearInterval(timer); } else{ obj.style.width = obj.offsetWidth + speed + 'px'; } },30) } }
添加回答
举报
0/150
提交
取消