Slider not working Properly?
HTML ------------------------------------------------------------------ <div> <button id="prev">Prev</button> <img id="image" src="resources/images/1.jpg"> <button id="next">Next</button> </div> JS------------------------------------------------------------------ var images = ["resources/images/1.jpg", "resources/images/2.jpg", "resources/images/3.jpg"]; var slider = document.getElementById("image"); var next = document.getElementById("next"); var currentImage = 0; next.addEventListener("click", nextFunc); function nextFunc() { currentImage ++; if (currentImage >= images.length) { currentImage = 0; } else { slider.src = images[currentImage]; } }