问答详情
源自:2-1 JS速度动画

怎么移动不了

window.onload=function(){

var   oDiv=document.getElementById('divl');

oDiv.onmouseover=function(){

startMove(0);}

oDiv.onmouseout=function(){

startMove(-200);}

}var timer=null;

function  startMove(iTarget){clearInterval(timer);

var   oDiv=document.getElementById('divl');

timer=setInterval(function()

{var speed=0;

if(oDiv.offsetLeft>iTarget){speed=-10;}

else{speed=10;}

if(oDiv.offsetLeft==iTarget){clearInterval(timer);}else{

oDiv.style.left=oDiv.offsetLeft+speed+'px';}},30)}

</script>  

  


提问者:慕粉3462803 2016-07-23 15:44

个回答

  • wajf
    2016-07-23 18:36:42

    我的跟你的一样,我的可以的!或许你的字母大小写符号的,中英文状态有错吧!仔细检查一下细节问题