停止所有子元素的jQuery动画 [英] Stop jQuery Animation for all Child Elements

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

问题描述

祝大家新年快乐!

我只是想问问是否有什么方法可以停止元素的所有儿童节点的jquery动画?我的意思是说如果我在文档中具有以下html结构,并且对容器内的所有div应用了不同的动画-有些也在queue = false等中使用.

I just wanted to ask if there was any way to stop jquery animation for ALL CHILD NODES of an element? I mean lets say if I have a below html structure in a document and I have applied different animations to all the div's inside the container - some also in queue=false etc.

<div id="container">
<div id="element-1"></div>
<div id="element-2"></div>
<div id="element-3"></div>
<div id="element-4"></div>
<div id="element-5"></div>
</div>

是否可以立即停止div中所有元素的所有动画?好吧,一个人马上就会想起下面的代码

Is there a way to stop all animations for all elements inside the div instantly? Well okay, one would recall the below code immediately

$('#element-1, #element-2, #element-3, #element-4, #element-5').stop(true);

,它应该立即停止所有元素.如果我们尝试

and it should stop all elements - instantly. And if we try

$('#element-1, #element-2, #element-3, #element-4, #element-5').stop(true, true);

这些元素应该跳转到最终结果-肯定对我不起作用.有什么要求,但是如果我同时具有300个元素动画,该怎么办-我肯定不能应用上述方法eh!

The elements should jump to end result - surely not working for me. Kind of what is required but what if I have 300 elements animating at the same instant - I surely cannot apply the above method eh!

我正在寻找

$('#container').stop(true,true);

可以进行一些调整吗?

推荐答案

您可以选择包装器中的所有元素,然后停止然后停止它们.对于您的html,这应该可以:

You can select all elements inside wrapper and stop then stop them. For your html this one should work:

$('#container').find('*').stop(true, true);

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

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