[英]jQuery fade-out DIV display after certain set time
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.我有以下代码,并希望在页面加载后的指定时间段(例如 5 秒)后隐藏 DIV(
.video-field-new
)。 Is that possible?那可能吗?
<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.如果我可以让它淡出而不是消失,因为用户会看到这种情况发生。
你可以这样做
$("#BodyField").delay(5000).fadeOut();
$(window).load(function(){
setTimeout(function(){ $('.video-field-new').fadeOut() }, 5000);
});
Try尝试
$('#div').fadeIn('fast').delay(1000).fadeOut('fast');
$('#div-inner').fadeIn('slow').delay(1000).hide(0);
Thanks谢谢
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/对于演示点击链接https://jsfiddle.net/kingtaherkings/133v70se/
You can also do something like this你也可以做这样的事情
$(document).ready(function(){
$('.video-field-new').fadeOut(5000)
})
$(selector).fadeOut(speed,easing,callback)
Parameter |参数| Description
描述
speed = Optional.速度= 可选。 Specifies the speed of the fading effect.
指定淡入淡出效果的速度。 Default value is 400 milliseconds
默认值为 400 毫秒
Possible values:可能的值:
easing = Optional.缓动= 可选。 Specifies the speed of the element in different points of the animation.
指定元素在动画不同点的速度。 Default value is "swing"
默认值为“摆动”
Possible values:可能的值:
callback = Optional.回调= 可选。 A function to be executed after the fadeOut() method is completed
一个在fadeOut()方法完成后要执行的函数
for more information check this doc https://www.w3schools.com/jquery/eff_fadeout.asp有关更多信息,请查看此文档https://www.w3schools.com/jquery/eff_fadeout.asp
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.