麻烦各位帮个忙!

麻烦朋友们帮忙看一下这一段代码:<style> #div1{width:150px; height:200px; background:yellow; position:absolute; left:-150px;} #div1 span{width:20px; height:60px; line-height:20px; background:#F99; position:absolute;right:-20px; top:70px;}</style><script type="text/javascript">window.onload=function(){ var oDiv=document.getElementById(✀div1✀); oDiv.onmouseover=function() { startMove(10,0) } oDiv.onmouseout=function() { startMove(-10,-150) }}var timer=null;function startMove(speed,iTarget){ var oDiv=document.getElementById(✀div1✀); clearInterval(timer); tiemr=setInterval(function(){ if(oDiv.offsetLeft==iTarget) { clearInterval(timer) } else { oDiv.style.left=oDiv.offsetLeft+speed+✀px✀; }; },30);};</script><div id="div1"> <span>分享到</span></div>鼠标移入时显示效果正常,但是鼠标移出的话,黄色div小块就会不停的左右移动,不能正常缩进-150这个位置。到底是哪里写错了啊?
2026年09月25日 14:10
有1个网友回答
网友(1):

上面的timer 到下面就写成了 tiemr 真粗心啊。