window.onload=function(){ var xin=document.getElementById('xin'); var speed=2; document.getElementById('dongzuo').onclick=function(){ speed+=5; setInterval(function(){ var old_top=xin.offsetTop; var new_top=old_top+speed; var old_left=xin.offsetLeft; var new_left=old_left+5; if(new_top>=365){ new_top=365; speed *= -0.8; } if(new_top<=0){ new_top=0; speed *= -0.8; } xin.style.top=new_top+'px'; xin.style.left=new_left+'px'; },10) } }
添加回答
举报
0/150
提交
取消