By Sam Deering

A jQuery Snippet for Displaying a Random Quote on Page Load

By Sam Deering

This is a simple jQuery code snippet that will display a random quote on your web page every time it loads. This could be useful for displaying different testimonials on your web page every time it is loaded, with a new one displayed every time.

var a = Math.random() + ""
var rand1 = a.charAt(5)
quotes = new Array
quotes[1] = "QUOTE #1"
quotes[2] = "QUOTE #2"
quotes[3] = "QUOTE #3"
quotes[4] = "QUOTE #4"
quotes[5] = "QUOTE #5"
quotes[6] = "QUOTE #6"
quotes[7] = "QUOTE #7"
quotes[8] = "QUOTE #8"
quotes[9] = "QUOTE #9"
quotes[0] = "QUOTE #10"
var quote = quotes[rand1]

" + quote + "


Login or Create Account to Comment
Login Create Account
Get the most important and interesting stories in tech. Straight to your inbox, daily.