var imgArr; $(document).ready(function(){ preload(["/vehiclephotos/1122006/huge/a5a9c404-7d29-4042-a0ce-f216d1588ddf.jpg", "/vehiclephotos/1122006/huge/65903d14-36fc-4c19-9bf3-64f62f7a58db.jpg", "/vehiclephotos/1122006/huge/15619658-a323-4355-a9f8-0e8bbed458b2.jpg", "/vehiclephotos/1122006/huge/2308e01e-2d72-4f39-9c3e-38c0d394d04a.jpg", "/vehiclephotos/1122006/huge/71faaff4-828d-4c01-8f07-d0274f24d576.jpg"]); $("#photo-main").attr("src","/vehiclephotos/1122006/huge/a5a9c404-7d29-4042-a0ce-f216d1588ddf.jpg"); }); function preload(arrayOfImages) { $(arrayOfImages).each(function(){ $('')[0].src = this; }); imgArr = arrayOfImages; }