Answer the question
In order to leave comments, you need to log in
How to make this autoplay slider?
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("dot");
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";
}
Answer the question
In order to leave comments, you need to log in
The simplest option that comes to mind is to put setTimeOut on the function function plusSlides(n) {
showSlides(slideIndex += n);
}
Is she the one flipping through the slides?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question