var imgArr; $(document).ready(function(){ preload(["/vehiclephotos/1161874/huge/83ba82f1-48a6-42f8-8394-7a3239122320.jpg", "/vehiclephotos/1161874/huge/c9f324d3-7f00-4b89-b110-af006093e16e.jpg", "/vehiclephotos/1161874/huge/265e3743-f3e1-4a7a-9e50-ac458a4dd43e.jpg", "/vehiclephotos/1161874/huge/6bbbdb2f-86d6-4955-9412-20bff4e6b2c7.jpg", "/vehiclephotos/1161874/huge/efd350ac-177c-434a-91ea-50e9f168fb64.jpg", "/vehiclephotos/1161874/huge/9d5ea989-b23a-4028-b97a-f50426ae9764.jpg", "/vehiclephotos/1161874/huge/e5533385-128c-424f-a8b3-f6ac5cebe2d7.jpg"]); $("#photo-main").attr("src","/vehiclephotos/1161874/huge/83ba82f1-48a6-42f8-8394-7a3239122320.jpg"); }); function preload(arrayOfImages) { $(arrayOfImages).each(function(){ $('')[0].src = this; }); imgArr = arrayOfImages; }