admin管理员组文章数量:1418083
I am not very experienced with javascript but I asume this is not a difficult problem. Never the less I am lost and am wondering how to make multiple div's fade in with a delay when a page loads, say 5-10 divs using Jquery. The following is the code I am using and need but modified so I can load 5+ div's:
<script>
$(".fade").hide(0).delay(1000).fadeIn(1000)
</script>
I am not very experienced with javascript but I asume this is not a difficult problem. Never the less I am lost and am wondering how to make multiple div's fade in with a delay when a page loads, say 5-10 divs using Jquery. The following is the code I am using and need but modified so I can load 5+ div's:
<script>
$(".fade").hide(0).delay(1000).fadeIn(1000)
</script>
Share
Improve this question
asked Aug 7, 2012 at 0:33
ZachZach
32 silver badges5 bronze badges
1
- This code works for me: jsfiddle/Gcq36. What's wrong with it? – Blender Commented Aug 7, 2012 at 0:36
3 Answers
Reset to default 3$(".fade, #anotherElement, #yetAnother, .etc").hide(0).delay(1000).fadeIn(1000)
It's called multiple selectors.
That code should work fine if the ".fade" elements have already been parsed when it runs - which won't be the case if you have placed that script block in the <head>
. If the script block is at the bottom of the body it will work, or if you put the code in a document ready handler so that it will run after the document has been parsed:
$(document).ready(function() {
$(".fade").hide(0).delay(1000).fadeIn(1000);
});
Demo: http://jsfiddle/nnnnnn/QHwge/
You don't have to do this with javascript, but the examples here all seem to work fine.
Here is an example using CSS:
.fade {
opacity: 1;
transition: opacity .25s ease-in-out;
-moz-transition: opacity .25s ease-in-out;
-webkit-transition: opacity .25s ease-in-out;
}
.fade:hover {
opacity: 0.5;
}
本文标签: javascriptJquery Delay and fadein multiple divs onloadStack Overflow
版权声明:本文标题:javascript - Jquery: Delay and fade-in multiple divs onload? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745282816a2651524.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论