Ive been trying to create this certain slideshow for a webpage I am making. Everytime Im trying to replace the images with an id tag, the slideshow freezes at the first picture. I just want a way to use the same method to create a slide show using div ids (since Im trying to write/edit on the panels). If there is an another method, please mention it also.
This is the code I am using for the images:
var pic = document.getElementById("car");
var Array = ["images/pic_1.jpg", "images/pic_2.jpg", "images/pic_3.jpg"];
var index = 0;
function myFunction() {
pic.setAttribute("src", Array[index]);
index++;
if (index >= Array.length) {
index = 0;
}
}
setInterval(myFunction, 1000);