jQuery一次显示一个元素? [英] jQuery Show one element at a time?
本文介绍了jQuery一次显示一个元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个列出了索引类的列表-在容器div淡入时一次显示这些类的最佳方法是什么?
I have a list that has indexed classes - what would be the best way to show these one at a time upon fadeIn of the container div?
推荐答案
给他们一个通用的类,然后执行 fadeIn()
[docs] 使用 each()
[docs] 方法,同时使用 delay()
<给定持续时间的i> [docs] 方法乘以循环索引.
Give them a common class, and do the fadeIn()
[docs] in a loop using the each()
[docs] method while delaying each one with the delay()
[docs] method for a given duration multiplied by the index of the loop.
$('li.someClass').hide().each(function( i ) {
$(this).delay( i * 400 ).fadeIn();
});
每个元素都比上一个元素晚400毫秒.
Each element will begin 400 milliseconds later than the previous.
示例: http://jsfiddle.net/4ANCj/
这篇关于jQuery一次显示一个元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文