left值变为0也停不了,请大佬帮忙
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
#div1{
width: 200px;
height: 200px;
background-color: red;
position: relative;
top: 0;
left: -200px;
}
#div1 span{
width: 20px;
height: 50px;
background-color: blue;
position: absolute;
left: 200px;
top: 75px;
}
</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+1+'px';}
},30)
}
</script>
</head>
<body>
<div id="div1">
<span id="分享">
分享
</span>
</div>
</body>
</html>