jQuery动画的多个元素的回调 [英] callback for jquery animation for multiple elements

查看:55
本文介绍了jQuery动画的多个元素的回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如您在此小提琴中看到的那样,我一次对多个元素进行了动画处理, 这是我所希望的.但是在下一步中,我想在所有元素的动画结束后再做一次.使用完成功能似乎无法实现,因为它是为每个完成的动画触发的(3个元素,完成回调的3倍). jQuery .animate() API也说:

As you can see at this Fiddle, I animate more than one element at once, which is happening as I wish. But in the next step, I would like to do things ONCE the animation for all elements is over. Which does not seem to be possible by using the complete-function, because it is it fired for EACH completed animation (3 elemets, 3 times complete callback). the jquery .animate() API also says:

如果对多个元素进行了动画处理,则对每个匹配的元素执行一次回调,而不对整个动画执行一次.

If multiple elements are animated, the callback is executed once per matched element, not once for the animation as a whole.

那么,您是否知道在完成每一个动画后都会触发一个事件该怎么办?

So, do you have any idea what I can do to have an event fired when every single animation has finished?

推荐答案

...animate(...).promise().done(function(){console.log("animate complete!")})

这篇关于jQuery动画的多个元素的回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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