var imgArr; $(document).ready(function(){ preload(["/vehiclephotos/1193842/huge/0f5c9eea-cc03-44ba-a5d6-483c36110c91.jpg", "/vehiclephotos/1193842/huge/d59df966-c091-404d-9b56-3bc28be79e16.jpg", "/vehiclephotos/1193842/huge/315621cf-cf03-456c-9809-874330605fdb.jpg", "/vehiclephotos/1193842/huge/28cac069-444d-419d-abcf-035e90391a73.jpg", "/vehiclephotos/1193842/huge/26418439-2e5f-436f-b8d6-8a87b3689728.jpg", "/vehiclephotos/1193842/huge/a66e57ae-952e-4406-9623-df9152a3236c.jpg", "/vehiclephotos/1193842/huge/d72bbb4d-1aca-47a1-bc73-9bf64d0a5f5c.jpg", "/vehiclephotos/1193842/huge/bef06f62-2427-474b-87da-fabfde6310f3.jpg"]); $("#photo-main").attr("src","/vehiclephotos/1193842/huge/0f5c9eea-cc03-44ba-a5d6-483c36110c91.jpg"); }); function preload(arrayOfImages) { $(arrayOfImages).each(function(){ $('')[0].src = this; }); imgArr = arrayOfImages; }