Javascript jQuery 淡入加载?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7861150/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
jQuery Fade-In OnLoad?
提问by Aaron Brewer
Okay what I am simply looking for is a short/easy script that will allow me to replace the DIV name so that I can have multiple divs on a page fadein once loaded (including images within them).
好吧,我只是在寻找一个简短/简单的脚本,它允许我替换 DIV 名称,以便我可以在加载后淡入淡入的页面上拥有多个 div(包括其中的图像)。
Any ideas?
有任何想法吗?
Thank you!
谢谢!
回答by Joseph Marikle
Give the divs a common class (e.g. "fade") and use code similar to this
给 div 一个公共类(例如“淡入淡出”)并使用类似于此的代码
$(document).ready(function(){
$(".fade").hide(0).delay(500).fadeIn(3000)
});
回答by Joost
Put this code in your javascript file, for each element you want to fade it add the class="fadeOnLoad"
code and make sure to add display: none
to the css for any elements you want to have hidden on load:
将此代码放在您的 javascript 文件中,为您想要淡化它的每个元素添加class="fadeOnLoad"
代码,并确保将display: none
您想要在加载时隐藏的任何元素添加到 css 中:
$(document).ready(function() {
$('.fadeOnLoad').fadeIn('slow');
);