sandraqu
sandraqu

Reputation: 1528

How do I add a fade in?

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

Answers (4)

Ben
Ben

Reputation: 16553

Use this method:

$('#quoteHome').hide().html(myQuotes[myRandom]).fadeIn('fast');

Upvotes: 1

idrumgood
idrumgood

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

Ali Tarhini
Ali Tarhini

Reputation: 5358

 $('#quoteHome').fadeIn();

 $('#quoteHome').fadeIn(1000); //duration in milliseconds

 $('#quoteHome').fadeIn('fast'); //speed

Upvotes: 0

Nick Craver
Nick Craver

Reputation: 630569

You can just chain a .hide() with a .fadeIn(), like this:

$('#quoteHome').html(myQuotes[myRandom]).hide().fadeIn();

Upvotes: 3

Related Questions