Reputation: 1528
How would I add a fade in to this?
$(document).ready(function(){
var myQuotes = new Array();
myQuotes[0] = "All is connected... ";
myQuotes[1] = "The best way";
myQuotes[2] = "Your work is to discover";
myQuotes[2] = "If success";
var myRandom = Math.floor(Math.random()*myQuotes.length);
$('#quoteHome').html(myQuotes[myRandom]);
});
Upvotes: 1
Views: 85
Reputation: 16553
Use this method:
$('#quoteHome').hide().html(myQuotes[myRandom]).fadeIn('fast');
Upvotes: 1
Reputation: 4934
couldn't be easier.
$('#quoteHome').html(myQuotes[myRandom]).fadeIn('slow');
Just make sure that #quoteHome
is set to display:none
from the getgo.
Upvotes: 0
Reputation: 5358
$('#quoteHome').fadeIn();
$('#quoteHome').fadeIn(1000); //duration in milliseconds
$('#quoteHome').fadeIn('fast'); //speed
Upvotes: 0
Reputation: 630569
You can just chain a .hide()
with a .fadeIn()
, like this:
$('#quoteHome').html(myQuotes[myRandom]).hide().fadeIn();
Upvotes: 3