This JavaSript in HTML for image Slideshow, how can understand the code?
var slideIndex = 1;
showSlides(slideIndex);
// Next/previous controls
function plusSlides(n) {
showSlides(slideIndex += n);
}
// Thumbnail image controls
function currentSlide(n) {
showSlides(slideIndex = n);
}
function showSlides(n) {
var i;
var slides = document.getElementsByClassName("mySlides");
var dots = document.getElementsByClassName("demo");
var captionText = document.getElementById("caption");
if (n > slides.length) {slideIndex = 1}
if (n < 1) {slideIndex = slides.length}
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" active", "");
}
slides[slideIndex-1].style.display = "block";
dots[slideIndex-1].className += " active";
captionText.innerHTML = dots[slideIndex-1].alt;
}
I have made comments on almost every line of code, explaining what each line does.
@Vandesm14 First off, great job! Upvoted!
The only one critique I have is that the following line is an incorrect explanation:
It should be:
@Vandesm14 Thank you very much for your help
@heyitsmarcus Oof. I forgot about that. Thanks.
@Vandesm14 Of course, but like I said, great job! I love seeing people helping out others!