jQuery(document).ready(function(){
$(".welcome").fadeOut(9500);
$(".freelance").fadeIn(10000);
$(".freelance").fadeOut(4500);
});
I want the welcome message to fadeOut slowly and then the other div to fadeIn its place and then fadeOut - obviously when the welcome box no longer exists.
<header>
<h1 class="left"><a href="index.html"></a></h1>
<div class="left yellowbox welcome"><p>Welcome to my portfolio.</p></div>
<div class="left greenbox freelance"><p>I am currently available for for work, contact me below.</p></div>
</header>
The jQuery fadeOut() method is used to fade out a visible element. Syntax: $(selector). fadeOut(speed,callback);
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.
fadeOut() the place will be removed at once. . show(duration) and . hide(duration) animate the size of element (also the opacity) to 100% and 0% and the place of elements is also animated in that duration.
You need to call the additional fadeIn()
and fadeOut
inside of a callback function to the first one. All animation methods (and many others) in jQuery allow for callbacks:
jQuery(document).ready(function(){
$(".welcome").fadeOut(9500,function(){
$(".freelance").fadeIn(10000, function(){
$(".freelance").fadeOut(4500);
});
});
});
This will cause .welcome
to fade out first. Once it's done fading out, .freelance
will fade in. Once it's done fading in, it will then fade out.
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