$(document).ready(function(){ var quoteSource=[ { quote: "Château du Wa Wabbit", name:"Wa Wabbit" }, { quote:"Village kanniboul", name:"Kanniboul Ebil" }, { quote:"Clos des Blops", name:"Blops Royaux" }, { quote:"Gelaxième Dimension", name:"Gelées Royales" }, { quote:"Laboratoire de Brumen Tinctorias", name:"Nelween" }, { quote:"Cale de l'Arche d'Otomaï", name:"Gourlo le Terrible" }, { quote:"Donjon des Craqueleurs", name:"Craqueleur Légendaire" }, { quote:"Repaire de Daïgoro", name:"Daïgoro" }, { quote:"Terrier du Wa Wabbit", name:"Wa Wobot" }, { quote:"Cimetière des Mastodontes", name:"Mantiscore" }, { quote:"Antre de la Reine Nyée", name:"Reine Nyée" }, { quote:"Domaine Ancestral", name:"Abraknyde Ancestral" }, { quote:"Bateau du Chouque", name:"Chouque" }, { quote:"Chapiteau des Magik Riktus", name:"Choudini" }, { quote:"Antre du Dragon Cochon", name:"Dragon Cochon" }, { quote:"Caverne du Koulosse", name:"Koulosse" }, { quote:"Tanière du Meulou", name:"Meulou" }, { quote:"Arbre de Moon", name:"Moon" }, { quote:"Théâtre de Dramak", name:"mMître des Pantins" }, { quote:"Fabrique de Malléfisk", name:"Malléfisk" } ]; $('#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