JavaScript load Images in an Array and Show in Image Source
I created an array of images function initialize(){ //add our 10 images to our array imgArray[imageNum++] = new imageItem(imageDir + "img1.jpg"); imgArray[imageNum++] = new imageItem(imageDir + "img2.jpg"); imgArray[imageNum++] = new imageItem(imageDir + "img3.jpg"); } var totalImgs = imgArray.length; I then create a function that is linked with a in my html file: <button id="startButton" onclick="startImage()">Start</button> function startImage(){ document.getElementById("pic").setAttribute("src", imgArray[0].src); } My image tag : <img id="pic" src="" height="300" width="500" border="0" alt=