? ?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)? ?? ? ??}
為什么我用margin-left來做一個速度動畫,效果出不來
汾汾學前端
2016-03-20 13:08:27