css样式代码
<style> div{ border: red 1px solid; border-radius:50%; width: 400px; height: 400px; position: absolute; } </style>
html代码 <div id="xq"> 小球 </div> <button οnclick="aaa()">点我开始</button> <button οnclick="end()">点我结束</button>
script里代码
<script> var time ; function aaa(){ time= window.setInterval("star()",100); } function star(){ var node=document.getElementById("xq"); var num= parseInt(window.getComputedStyle(node).left); num+=20; node.style.left=num+"px"; } function end(){ window.clearInterval(time); } </script>