然后在jquery中加载div然后延迟加载 [英] load div then delay load next in jquery
问题描述
嗨我有一个画廊已经离开浮动的div,图片是每个div的背景,我想要的是每个图片加载稍有延迟所以首先加载然后等待5秒然后第2等在一个序列中,我已经在网站上看到了它,但是如果可能的话,在jquery中一直忘记将它加入书签。
Hi I have a gallery which has left floated divs in, the pictures are the backgrounds for each div, what i want is for each picture to load with a slight delay so first will load then wait say 5 seconds then the 2nd etc in a sequence, i have seen it on sites but keep forgetting to bookmark it, if possible in jquery.
我确实尝试过查询,但我只能得到很多信息fadein当我希望每个div淡入时
i did try query but i can only get the whole lot to fadein when i want each div to fade in
所以使用以下代码:
<div id="parent">
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
</div>
子元素将一次淡入一个。第一个然后延迟5秒,然后是下一个等等。
the child elements will fade in one at a time. the first then a delay of 5 seconds and then the next and so on.
谢谢
推荐答案
你可以使用
$('#parent .child')
.hide()
.each(function(index){
var _this = this;
setTimeout( function(){ $(_this).fadeIn(); }, 5000*index );
});
演示 http://jsfiddle.net/gaby/eGWx9/1/
这篇关于然后在jquery中加载div然后延迟加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!