jquery:如何延迟each()被触发
如何延迟 each()
被触发?
这是延迟每个框在给定的特定时间淡出的代码。
$(document).ready(function(){
var delay = 0;
$('.block-item:lt(16)').each(function(){
//^^ do for every instance less than the 16th (starting at 0)
$(this).delay(delay).animate({
opacity:0
},500);
delay += 500;
});
});
但我想在触发 each()
之前延迟大约五秒。可行吗?
这是链接。
How can I delay each()
from being triggered?
This is the code that delays each box from fading out at certain time given.
$(document).ready(function(){
var delay = 0;
$('.block-item:lt(16)').each(function(){
//^^ do for every instance less than the 16th (starting at 0)
$(this).delay(delay).animate({
opacity:0
},500);
delay += 500;
});
});
But I want to delay about five second before the each()
is triggered. Is it feasible?
Here is the link.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
如果只是延迟初始动画的问题,为什么不从延迟 5000 开始呢?
http://jsfiddle.net/QAWTy/1/
If it is just a matter of delaying the initial animation, why not just start with a 5000 delay?
http://jsfiddle.net/QAWTy/1/
是的,你可以,就像这样
Yes you can, like this
您的意思是在首次呼叫每个人之前等待 5 秒钟吗?如果是这样,请使用
setTimeout
setTimeout 参考现场演示
Do you mean wait 5 seconds just before the initial call to each? If so use
setTimeout
setTimeout ReferenceLive Demo
您可以使用 setInterval 方法来实现此目的。
You can use
setInterval
method to achieve this.利用一些新功能http://jsfiddle.net/7czu4/
Making use of some new features http://jsfiddle.net/7czu4/
这是我专门为此目的制作的一个片段。
您可以调用 iniFadeChildren($('.parent'), 'li', 500)
而父母身上的所有的礼,都会一个接一个地消逝
Here is a snippet I did specially for this purpose.
You can call iniFadeChildren($('.parent'), 'li', 500)
And all the li in parent are gonna fade one after another