var imgArr; $(document).ready(function(){ preload(["/vehiclephotos/1078377/huge/9f71dfb7-e355-47e8-9b81-c906bfcb2fce.jpg", "/vehiclephotos/1078377/huge/ec0a3fc1-1eca-4a61-abc3-847ed401f35a.jpg", "/vehiclephotos/1078377/huge/e3b238e3-7606-4455-a75f-42abd1e76d2a.jpg", "/vehiclephotos/1078377/huge/12c063e2-4919-4f04-8829-0ea39c616b60.jpg", "/vehiclephotos/1078377/huge/b3159493-b19c-4144-86ab-078bf282ad79.jpg", "/vehiclephotos/1078377/huge/10c90ae2-8355-420e-917f-cb151feec22f.jpg", "/vehiclephotos/1078377/huge/03f474ff-7f7d-4ff8-9891-a4a910a67df1.jpg"]); $("#photo-main").attr("src","/vehiclephotos/1078377/huge/9f71dfb7-e355-47e8-9b81-c906bfcb2fce.jpg"); }); function preload(arrayOfImages) { $(arrayOfImages).each(function(){ $('')[0].src = this; }); imgArr = arrayOfImages; }