开发者

how to combine these 2 jquery animations code into one

开发者 https://www.devze.com 2023-01-16 05:45 出处:网络
here is the code so far. what i want is firstthe #spider to easeOutBounce then startdoing 开发者_如何学Gothis animation

here is the code so far. what i want is first the #spider to easeOutBounce then start doing 开发者_如何学Gothis animation

  $("#spider").animate({top:"-=20px"},1000).animate({top:"+=20px"}, 1000);

here is all the codes

   $(document).ready(function() {
     setTimeout("animation()",300);
  });

  function animation(){
       spider();
  }

  function spider(){
     $("#spider").animate({top: '200px' }, {queue:false, duration:600, easing:'easeOutBounce'});
      $("#spider").animate({top:"-=20px"},1000).animate({top:"+=20px"}, 1000);
      setTimeout("spider()",2000);
  }

thanks


you mean callback ??

function spider(){
   $("#spider").animate({top: '200px' }, 600, 'easeOutBounce',
       function() {
         $(this).animate({top:"-=20px"},1000).animate({top:"+=20px"}, 1000);
   });
}
0

精彩评论

暂无评论...
验证码 换一张
取 消