var timer=null;window.onload=function () { var obigbox=document.getElementById('bigbox'); var osmallbox=document.getElementById('smallbox'); osmallbox.onmouseover=function(){ startMove(); }}function startMove () { var obigbox=document.getElementById('bigbox'); clearInterval(timer); timer=setInterval(function () { console.log("hello"); if (obigbox.offsetLeft==0) { clearInterval(timer); } else{ obigbox.style.cssText='margin-left:'+obigbox.offsetLeft+10+'px;' } console.log(obigbox.offsetLeft+' '); },30) }
添加回答
举报
0/150
提交
取消