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?
<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.
The jQuery fadeOut() method is used to fade out a visible element. Syntax: $(selector).fadeOut(speed,callback); The optional speed parameter specifies the duration of the effect.
The fadeIn method displays the element by fading it to opaque. The fadeOut method hides the element by fading it to transparent. Note – jQuery does the fading by changing the opacity of the element.
Main difference between FadeIn, FadeOut vs hide, Show is When you use FadeIn and fadeout Its remove line Slowly Like Opacity will 100 to 0 in a few mili-second but On other hand hide, Show will remove the line immediately Without wasting any mili-second.
fadeOut() method animates the opacity of the matched elements. Once the opacity reaches 0, the display style property is set to none , so the element no longer affects the layout of the page. Durations are given in milliseconds; higher values indicate slower animations, not faster ones.
You can do it in this way
$("#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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With