I'm working on creating a versatile "slideshow" feature that can be used for various elements. Currently, I am testing it on a div that contains paragraph text taken from my HTML document and represented as container1, container2, and container3. The Clicky() function is triggered by the onclick event on a button.
let slideshow_elements = ["container1", "container2", "container3"];
for(let i = 1; i < slideshow_elements.length; i++) {
document.getElementById(slideshow_elements[i]).style.display = "none";
}
let current_slide = 0
function clicky() {
document.getElementById(slideshow_elements[current_slide]).style.display = "none";
current_slide = current_slide + 1
document.getElementById(slideshow_elements[current_slide]).style.display = "block";
}
Once container3 is displayed, containers 1 and 2 are set to display:none. However, when cycling back to container1, it remains hidden. This means that the sequence only works once in the end.
I would greatly appreciate any assistance with this issue.