如何父元素等到孩子的停止动画() [英] how to wait on parent element until childs stop animate()

查看:101
本文介绍了如何父元素等到孩子的停止动画()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一堆LI元素动画(了slideDown)内的UL。李后完成自己的动画我想补充以下UL A-HREF元素。

I got bunch of LI elements animating (slideDown) inside UL. After LI finish their animation I want to add A-HREF element below UL.

有一个问题 - 如果我用

There is a problem - if I use

$('li').animate(SPEED, callback)

等待LIS完成其动画,我的回调将被称为n次(N =算LI) - 如果我有20 LIS,20 A-的HREF将波纹管加入UL。我需要onlt一个A HREF,在换句话说,我需要等待,直到完成LI他们的动画,然后火一把回调。

to wait for LIs finish its animation, my callback will be called n-times (n = count LI) - if I have 20 LIs, 20 A-HREFs will be added bellow UL. I need onlt one A-HREF, in the other words, I need to wait, until LI finish theirs animation and then fire ONE callback.

任何想法?

推荐答案

尝试,

$('li').animate(SPEED, callback);

callback = function(){
   if ($(this).siblings(':animated').length < 1) { // check if other li's are still animating...
      // do parent animation or anything here...
   }
}

这篇关于如何父元素等到孩子的停止动画()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆