.box2{}
.box2{width: 200px; height: 200px; background: red; border-radius: 50%;position: relative;}
.box3{width: 800px; height: 500px; border:1px solid red;}
开始
停止
var lr=600;
var tb=300;
var i=0;
var j=0;
var box=document.getElementById('box');
var start=document.getElementById('start');
var stop=document.getElementById('stop');
start.οnclick=function(){
start.style.display='none';
stop.style.display='inline';
var time=setInterval(function(){
box.style.left=i+'px';
box.style.top=j+'px';
if (i>lr) {
lr=0;
i--;
}
if(i<=lr){
lr=600;
i++;
}
if (j>tb) {
tb=0;
j--;
}
if (j<=tb) {
tb=300;
j++
}
stop.οnclick=function(){
clearInterval(time);
stop.style.display='none';
start.style.display='inline';
}
},5);
}