很拉风很拉风的仔仔
2016-08-10 00:12

<script type="text/javascript">
window.onload=function(){
var box1= document.getElementById("box1");
box1.onmouseover=function(){
mvfn1();
}
};
var timer = null ;
function mvfn1(){
clearInterval(timer);
var box1= document.getElementById("box1");
var timer=setInterval(function(){
if (box1.offsetLeft>=0) {
clearInterval(timer);
} else{
box1.style.left=box1.offsetLeft+1+"px";
}
},30);
};
</script>
这样你就把全局变量变成局部变量了
JS动画效果
113910 学习 · 1502 问题
相似问题