能否不使用object.offsetLeft
<script> window.onload=function(){ var movepart=document.getElementById("movepart"); movepart.onmouseover=function(){ rightmove(0); } movepart.onmouseout=function(){ rightmove(-1000); } } var funa=null; function rightmove (target) { clearInterval(funa); var movepart=document.getElementById("movepart"); funa=setInterval(function(){ var speed=0; if (movepart.offsetLeft < target) { speed=10; } if (movepart.offsetLeft > target) { speed=-10; } if (movepart.offsetLeft == target) { clearInterval(funa); } else{ movepart.style.left=movepart.offsetLeft+speed+'px'; } },1) } </script>
之前好像在哪里看到只使用object.style.left,就可以控制的动画的,如何实现?