var imgArr; $(document).ready(function(){ preload(["/vehiclephotos/1180055/huge/68a83f62-470f-4547-b1a4-a852c7b37639.jpg", "/vehiclephotos/1180055/huge/744dbe0d-5441-424b-a171-60a370837246.jpg", "/vehiclephotos/1180055/huge/0dd730e0-7950-478a-aa31-3230cc39f374.jpg", "/vehiclephotos/1180055/huge/f52e8382-3945-454b-a019-b933d08093ed.jpg", "/vehiclephotos/1180055/huge/f5f7a496-3c34-42d3-bdfd-a46a03b42e12.jpg"]); $("#photo-main").attr("src","/vehiclephotos/1180055/huge/68a83f62-470f-4547-b1a4-a852c7b37639.jpg"); }); function preload(arrayOfImages) { $(arrayOfImages).each(function(){ $('')[0].src = this; }); imgArr = arrayOfImages; }