为什么我用margin-left来做速度动画,出不来效果
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)
}