var imgArr; $(document).ready(function(){ preload(["/vehiclephotos/1172128/huge/41e90e32-958a-47e2-897f-b5b3e6c713e5.jpg", "/vehiclephotos/1172128/huge/6375259e-3c12-4475-a6c2-d309f15fee19.jpg", "/vehiclephotos/1172128/huge/9962d28c-2507-46a4-a6b8-9c9089fcbc03.jpg", "/vehiclephotos/1172128/huge/268ed746-a9fd-4db4-887d-d0a8e57feec8.jpg", "/vehiclephotos/1172128/huge/c3a23c83-9dc1-4f00-aa7a-df4ae1ceaa5e.jpg"]); $("#photo-main").attr("src","/vehiclephotos/1172128/huge/41e90e32-958a-47e2-897f-b5b3e6c713e5.jpg"); }); function preload(arrayOfImages) { $(arrayOfImages).each(function(){ $('')[0].src = this; }); imgArr = arrayOfImages; }