$(document).ready(function(){ var quoteSource=[ { quote: "Canopée du Kimbo", name:"Kimbo" }, { quote:"Salle du Minotot", name:"Minotot" }, { quote:"Hypogée de l'Obsidiantre", name:"Obsidiantre" }, { quote:"Grotte de Kanigroula", name:"Kanigroula" }, { quote:"Plateau de Ush", name:"Ush Galesh" }, { quote:"Cavernes Givrefoux", name:"Tengu Givrefoux" }, { quote:"Boyau du Père Ver", name:"Père Ver" }, { quote:"Horologium de XLII", name:"XLII" }, { quote:"Antre du Korriandre", name:"Korriandre" }, { quote:"Antre du Kralamoure Géant", name:"Kralamoure Géant" }, { quote:"Grotte du Bworker", name:"Bworker" }, { quote:"Temple du Grand Ougah", name:"Ougah" }, { quote:"Cave du Toxoliath", name:"Toxoliath" }, { quote:"Cavernes du Kolosso", name:"Kolosso" }, { quote:"Cavernes Nourricières", name:"Fuji Givrefoux Nourricière" }, { quote:"Mine de Sakaï", name:"N (nique Grolloum !)" }, { quote:"Antichambre du Glourséleste", name:"Glourséleste" }, { quote:"Pyramide d'Ombre", name:"Ombre" }, { quote:"Camp du Comte Razof", name:"Comte Razof" } ]; $('#quoteButton').click(function(evt){ //define the containers of the info we target var quote = $('#quoteContainer p').text(); var quoteGenius = $('#quoteGenius').text(); //prevent browser's default action evt.preventDefault(); //getting a new random number to attach to a quote and setting a limit var sourceLength = quoteSource.length; var randomNumber= Math.floor(Math.random()*sourceLength); //set a new quote for(i=0;i<=sourceLength;i+=1){ var newQuoteText = quoteSource[randomNumber].quote; var newQuoteGenius = quoteSource[randomNumber].name; //console.log(newQuoteText,newQuoteGenius); var timeAnimation = 500; var quoteContainer = $('#quoteContainer'); //fade out animation with callback quoteContainer.fadeOut(timeAnimation, function(){ quoteContainer.html(''); quoteContainer.append('

'+newQuoteText+'

'+'

'+'- '+newQuoteGenius+'

'); //fadein animation. quoteContainer.fadeIn(timeAnimation); }); break; };//end for loop });//end quoteButton function });//end document ready