Use jquery to create a multidimensional array
Posted
by Simon M White
on Stack Overflow
See other posts from Stack Overflow
or by Simon M White
Published on 2010-03-22T13:55:15Z
Indexed on
2010/03/22
14:01 UTC
Read the original article
Hit count: 443
jQuery
I'd like to use jquery and a multidemensional array to show a random quote plus the name of the individual who wrote it as a separate item. I'll then be able to use css to style them differently. The quote will change upon page refresh.
So far i have this code which combines the quote and the name and person who wrote it:
$(document).ready(function(){
var myQuotes = new Array();
myQuotes[0] = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec in tortor mauris. Peter Jones, Dragons Den";
myQuotes[1] = "Curabitur interdum, nibh et fringilla facilisis, lacus ipsum pulvinar mauris, eu facilisis justo arcu eget diam. Duis id sagittis elit. Theo Pathetis, Dragons Den";
myQuotes[2] = "Vivamus purus purus, tincidunt et porttitor et, euismod sit amet urna. Etiam sollicitudin eros nec metus pretium scelerisque. James Caan, Dragons Den";
var myRandom = Math.floor(Math.random()*myQuotes.length);
$('.quote-holder blockquote span').html(myQuotes[myRandom]);
});
any help would be greatly appreciated.
© Stack Overflow or respective owner