如何在jquery上逐个显示每个div?

嘿,我不想在我的页面上做出很酷的效果,我在想,如何在加载时隐藏所有内容并逐个显示每个div? 如果这是一个坏主意,你能帮助我一个更好的主意吗?

EDIt:使用$(“div”)。each()jQuery函数。 EDIT2:儿童的孩子。

EDIT3:



A carregar, aguarde...

感谢所有JoséMoreira

你可以使用这样的东西:

 $(function() { // Start showing the divs showDiv(); }); function showDiv() { // If there are hidden divs left if($('div:hidden').length) { // Fade the first of them in $('div:hidden:first').fadeIn(); // And wait one second before fading in the next one setTimeout(showDiv, 1000); } } 

找到下一个隐藏的div并在每一秒都淡出它。 只需使用CSS的display: none;隐藏你想要显示的div display: none; 预先。


如果你出于某些奇怪的原因必须使用each函数,这可能会有用..有点。

 $(function() { $('div:hidden').each(function(index) { setTimeout(function(el) { el.fadeIn(); }, index * 1000, $(this)); }); }); 

或者你可以使用这个插件: https : //github.com/Devlart/Jquery-AnimateOnebyOne

尝试下一个代码:

 $('div').hide().each(function(index, domElement) { $(this).slideDown("slow"); // Wait for the end of the animation somehow... })