仿照老师的代码做了js的运动效果,可为啥停不下来呢,求帮忙
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>Document</title>
<style type="text/css">
#div1{width:200px;height:150px;left:-200px;position:relative;background-color:red;}
#share{width:50px;height:100px;position:absolute;background-color:blue;left:200px;}
</style>
<script>
window.onload=function(){
var oDiv=document.getElementById("div1");
oDiv.onmouseover=function(){
startMove();
}
}
var timer=null;
function startMove(){
var oDiv=document.getElementById("div1");
timer=setInterval(function(){
if(oDiv.offsetLeft==0)
{clearInterval(timer);}
else
{oDiv.style.left=oDiv.offsetLeft+10+'px';}
},30)
}
</script>
</head>
<body>
<div id="div1">
<span id="share">分享</span>
</div>
</body>
</html>