var imgArr; $(document).ready(function(){ preload(["/vehiclephotos/1150692/huge/adb8ff48-5747-4d8e-bc49-16752fc1c36f.jpg", "/vehiclephotos/1150692/huge/523457bc-cc5e-48cd-b094-d09628d576a5.jpg", "/vehiclephotos/1150692/huge/1e8b0d5d-035b-457a-8540-b307f5b7cfe9.jpg", "/vehiclephotos/1150692/huge/f527357b-0ad7-4b6c-8e27-0d4336c90b34.jpg", "/vehiclephotos/1150692/huge/57d89b8a-d552-4169-99d3-4cb4bab2a4d7.jpg", "/vehiclephotos/1150692/huge/685b55d4-e261-45b5-b9ce-ca8974b3267d.jpg", "/vehiclephotos/1150692/huge/003b00bd-720d-4898-951a-0c925300314c.jpg", "/vehiclephotos/1150692/huge/f729c823-0c13-4bf6-a384-c1fd1d8d3968.jpg"]); $("#photo-main").attr("src","/vehiclephotos/1150692/huge/adb8ff48-5747-4d8e-bc49-16752fc1c36f.jpg"); }); function preload(arrayOfImages) { $(arrayOfImages).each(function(){ $('')[0].src = this; }); imgArr = arrayOfImages; }