Javascript 在Jquery中设置长方体动画

Javascript 在Jquery中设置长方体动画,javascript,jquery,Javascript,Jquery,我正在尝试在Jquery中设置一个长方体的动画。基本上,我只是想把盒子打开 以正方形的路径移动。我可以让它向右移动,然后向下移动,但之后它就什么也不做了。有什么建议吗 $(document).ready(function(){ $('#box').css({'height':'100px','width':'100px','background-color':'black', 'position':'absolute','marginTop':'70px'}); $('#box').

我正在尝试在Jquery中设置一个长方体的动画。基本上,我只是想把盒子打开 以正方形的路径移动。我可以让它向右移动,然后向下移动,但之后它就什么也不做了。有什么建议吗

$(document).ready(function(){

  $('#box').css({'height':'100px','width':'100px','background-color':'black', 'position':'absolute','marginTop':'70px'});

  $('#box').animate({'left':'1000px'},3000,'swing', function(){
    $('#box'). animate({'top':'500px'},3000,'swing',function(){
    $('#box'). animate({'right':'1000px'},3000,'swing')
   })
  })
});
小编辑

$(document).ready(function(){

  $('#box').css({'height':'100px','width':'100px','background-color':'black', 'position':'absolute','marginTop':'70px'});

  $('#box').animate({'left':'1000px'},3000,'swing', function(){
    $('#box').animate({'top':'500px'},3000,'swing',function(){
      $('#box').animate({'left':'0px'},3000,'swing');
    });
  });
});
小编辑

$(document).ready(function(){

  $('#box').css({'height':'100px','width':'100px','background-color':'black', 'position':'absolute','marginTop':'70px'});

  $('#box').animate({'left':'1000px'},3000,'swing', function(){
    $('#box').animate({'top':'500px'},3000,'swing',function(){
      $('#box').animate({'left':'0px'},3000,'swing');
    });
  });
});
小编辑

$(document).ready(function(){

  $('#box').css({'height':'100px','width':'100px','background-color':'black', 'position':'absolute','marginTop':'70px'});

  $('#box').animate({'left':'1000px'},3000,'swing', function(){
    $('#box').animate({'top':'500px'},3000,'swing',function(){
      $('#box').animate({'left':'0px'},3000,'swing');
    });
  });
});
小编辑

$(document).ready(function(){

  $('#box').css({'height':'100px','width':'100px','background-color':'black', 'position':'absolute','marginTop':'70px'});

  $('#box').animate({'left':'1000px'},3000,'swing', function(){
    $('#box').animate({'top':'500px'},3000,'swing',function(){
      $('#box').animate({'left':'0px'},3000,'swing');
    });
  });
});

使用
'left':'0px'
代替
'right':'1000px'
。尝试以下操作:

$(document).ready(function(){
$('#box').css({'height':'100px','width':'100px','background-color':'black', 'position':'absolute','marginTop':'70px'});
$('#box').animate({'left':'1000px'},3000,'swing', function(){
$('#box').animate({'top':'500px'},3000,'swing',function(){
$('#box').animate({'left':'0px'},3000,'swing')
})})});

使用
'left':'0px'
而不是
'right':'1000px'
。尝试以下操作:

$(document).ready(function(){
$('#box').css({'height':'100px','width':'100px','background-color':'black', 'position':'absolute','marginTop':'70px'});
$('#box').animate({'left':'1000px'},3000,'swing', function(){
$('#box').animate({'top':'500px'},3000,'swing',function(){
$('#box').animate({'left':'0px'},3000,'swing')
})})});

使用
'left':'0px'
而不是
'right':'1000px'
。尝试以下操作:

$(document).ready(function(){
$('#box').css({'height':'100px','width':'100px','background-color':'black', 'position':'absolute','marginTop':'70px'});
$('#box').animate({'left':'1000px'},3000,'swing', function(){
$('#box').animate({'top':'500px'},3000,'swing',function(){
$('#box').animate({'left':'0px'},3000,'swing')
})})});

使用
'left':'0px'
而不是
'right':'1000px'
。尝试以下操作:

$(document).ready(function(){
$('#box').css({'height':'100px','width':'100px','background-color':'black', 'position':'absolute','marginTop':'70px'});
$('#box').animate({'left':'1000px'},3000,'swing', function(){
$('#box').animate({'top':'500px'},3000,'swing',function(){
$('#box').animate({'left':'0px'},3000,'swing')
})})});