jQuery stop(true, true) to jump to end of all animations in queue

前端 未结 4 1510
野性不改
野性不改 2021-02-14 08:19

I have been using jQuery\'s stop(true, true) method to clear running animations so the next one starts immediately. I noticed that the first parameter, clearQ

4条回答
  •  眼角桃花
    2021-02-14 08:59

    Chaining multiple stop(false, true) makes sense. Instead of hard-coding a fixed number of chained calls, you could check the queue length:

    while ($(this).queue().length) {
        $(this).stop(false, true);
    }
    

    Demo: http://jsfiddle.net/AB33X/

提交回复
热议问题