How do I chain or queue custom functions using JQuery?

前端 未结 15 1408
暗喜
暗喜 2020-12-04 19:49

I have multiple functions the do different animations to different parts of the HTML. I would like to chain or queue these functions so they will run the animations sequenti

15条回答
  •  既然无缘
    2020-12-04 20:32

    I would run the second as a callback function:

    $('div#animateTest1').animate({ left: '+=200' }, 2000, function(){
        two();
    });
    

    which would run two() when first animation finishes, if you have more animations on timed queue for such cases i use jquery timer plugin instead setTimeout(), which comes very handy in some cases.

提交回复
热议问题