var imgArr; $(document).ready(function(){ preload(["/vehiclephotos/1087279/huge/dc644d63-acd8-4162-9f11-670d2271a35d.jpg", "/vehiclephotos/1087279/huge/6dfbc461-0e86-42d4-8c98-18d9cad69954.jpg", "/vehiclephotos/1087279/huge/2c0a11fe-0a71-4a4f-b34b-09730c91eb27.jpg", "/vehiclephotos/1087279/huge/446c2c45-5a41-46dd-b879-956b3f0d3781.jpg", "/vehiclephotos/1087279/huge/860565ab-47f3-4820-8ab9-bfed1aabeb8b.jpg", "/vehiclephotos/1087279/huge/c7286fc8-8b1c-4486-80de-d9b8f79d5236.jpg"]); $("#photo-main").attr("src","/vehiclephotos/1087279/huge/dc644d63-acd8-4162-9f11-670d2271a35d.jpg"); }); function preload(arrayOfImages) { $(arrayOfImages).each(function(){ $('')[0].src = this; }); imgArr = arrayOfImages; }