jQuery 一定时间后jQuery淡出DIV显示
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15118802/
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-out DIV display after certain set time
提问by Dan
I have the following code and would like to hide a DIV (.video-field-new
) after a specified amount of time after the page loads, for example 5 seconds. Is that possible?
我有以下代码,并希望.video-field-new
在页面加载后的指定时间后隐藏 DIV ( ),例如 5 秒。那可能吗?
<div id="BodyField">
<div class="video-field-new"></div>
</div>
And bonus if I could have it fade-out instead of just disappearing as the user will see this occurring.
如果我可以让它淡出而不是消失,因为用户会看到这种情况发生,还有奖金。
回答by Starx
You can do it in this way
你可以这样做
$("#BodyField").delay(5000).fadeOut();
回答by Denys Séguret
$(window).load(function(){
setTimeout(function(){ $('.video-field-new').fadeOut() }, 5000);
});
回答by subindas pm
Try
尝试
$('#div').fadeIn('fast').delay(1000).fadeOut('fast');
$('#div-inner').fadeIn('slow').delay(1000).hide(0);
Thanks
谢谢
回答by imtaher
Even We can do like this: in html
即使我们可以这样做:在 html
<div id="BodyField">
<div class="video-field-new">
<p>This is your DIV with text which will fade Out after delay 5s using jQuery</p>
<p>This is your DIV with text which will fade Out after delay 5s using jQuery</p>
<p>This is your DIV with text which will fade Out after delay 5s using jQuery</p>
<p>This is your DIV with text which will fade Out after delay 5s using jQuery</p>
</div>
</div>
in js:
在js中:
$(function() {
$('.video-field-new').delay(5000).show().fadeOut('slow');
});
in css:
在 CSS 中:
div {
width:200px;
height:80px;
float:left; }
For Demo Click on Link https://jsfiddle.net/kingtaherkings/133v70se/