Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

110
Views
How add automatic functionality to this slideshow?

I'm happy with how this slideshow works, but I would like it to be automatic after 3 seconds in the event the user doesn't manually advance the slide.

var slideIndex = 1;
showSlides(slideIndex);

function plusSlides(n) {
  showSlides(slideIndex += n);
}

function currentSlide(n) {
  showSlides(slideIndex = n);
}

function showSlides(n) {
  var i;
  var slides = document.getElementsByClassName("mySlides");
  if (n > slides.length) {
    slideIndex = 1
  }
  if (n < 1) {
    slideIndex = slides.length
  }
  for (i = 0; i < slides.length; i++) {
    slides[i].classList.remove("active");
    
  }
  slides[slideIndex - 1].classList.add("active");
};
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can use setInverval to automatically execute plusSlides at regular intervals. If the user interacts manually, you can use clearInterval to stop the automatic advancement of slides.

  var interval = setInterval(function() {
      plusSlides(1)
  }, 3000);

This would advance the slide by one every 3000ms (3 seconds). If you now want to disable the automatic advancement (maybe because a user interacted with something) you can use:

clearInterval(interval);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!