定时器前面一旦加了var 为什么就会抖动
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>下拉菜单</title>
<style type="text/css">
*{margin:0;padding: 0;font-size: 13px;}
div{height:300px;width:200px;position: relative;left:-200px;top:0;background: red;}
span{width:20px;height:50px;background: blue;position: absolute;left:200px;top:75px;}
</style>
<script>
window.onload=function(){
var oDiv=document.getElementById('div1');
oDiv.onmouseover=function(){
startMove();
}
oDiv.onmouseout=function(){
startMove1();
}
}
var int=null;
function startMove(){
clearInterval(int);
var oDiv=document.getElementById('div1');
var int=setInterval(function(){if(oDiv.offsetLeft==0)
{
clearInterval;
}
else
{
oDiv.style.left=oDiv.offsetLeft+1+'px';
}},30);
}
function startMove1(){
clearInterval(int);
var oDiv=document.getElementById('div1');
var int=setInterval(function(){if(oDiv.offsetLeft==-200)
{
clearInterval;
}
else
{
oDiv.style.left=oDiv.offsetLeft-1+'px';
}},30);
}
</script>
</head>
<body>
<div id="div1"><span id="share">分享</span></div>
</body>
</html>