Callback animation to begin only after ALL children have finished animating

后端 未结 2 1202
陌清茗
陌清茗 2021-01-13 04:08

I have a div wherein I would like to fade all of the child elements out at once, but fade in a new element but only after all children have completed fading out. Using my c

2条回答
  •  我在风中等你
    2021-01-13 04:34

    $('#DIV').children().fadeOut("slow", function() {
        if($('#DIV').children().filter(':animated').length == 1) $('#Message').fadeIn("slow");
    });
    

    Basically count how many are still animating, and when there is only one left, run the callback.

    This also makes your callback run just once, not once per element.

提交回复
热议问题