<script type="text/javascript"> window.onload=function(){var oDiv=document.getElementById('div1');//鼠标移入oDiv.onmouseover=function(){ startmove(0);}//鼠标移出oDiv.onmouseout=function(){ startmove(-200); }}var timer=null;function startmove(target){ clearInterval(timer); var oDiv=document.getElementById('div1'); timer=setInterval(function(){ var speed=(target-oDiv.offsetLeft)/10; speed=speed>0?Math.ceil(speed):Math.floor(speed); if(oDiv.offsetLeft==target){ clearInterval(timer); } else { oDiv.style.left=oDiv.offsetLeft+speed+'px'; } },30);} </script>
添加回答
举报
0/150
提交
取消