Not sure why jQuery would need to be involved, since any jQuery would
just use JavaScript's ".random()" anyways, so why complicate things?

var x = Math.floor(Math.random() * theImages.length);
var ThisRandomImage = theImages[x - 1];





On Jun 8, 6:49 pm, Nic Hubbard <nnhubb...@gmail.com> wrote:
> I have some image URLs stored in an array.  I then want to be able to
> print out one of those image URLs randomly on page load.  What would
> be the best method to do this in jQuery?
>
> My array looks like:
>
> var theImages = new Array()
> theImages[1] = 'http://www.puc.edu/__data/assets/image/0014/16007/
> visual_arts1.jpg'
> theImages[2] = 'http://www.puc.edu/__data/assets/image/0015/16008/
> visual_arts2.jpg'
> theImages[3] = 'http://www.puc.edu/__data/assets/image/0017/16208/
> visual_arts3.jpg'
> theImages[4] = 'http://www.puc.edu/__data/assets/image/0018/19035/
> visual_arts4.jpg'

Reply via email to