Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

252
Vistas
Autoplay in slider with js

let left = document.querySelector('.left');
let right = document.querySelector('.right');
let img = document.querySelector('.imgs');
let imgs = document.querySelectorAll('img');

let index = 0;


function rightimg() {
  right.addEventListener('click', function () {
    index++;
    if (index > imgs.length - 1) {
      index = 0;
    }
    img.style.transform = `translateX(${-index * 500}px)`;
    console.log(img);
  });
}

// setInterval(rightimg, 2000);

left.addEventListener('click', function () {
  index--;
  if (index < 0) {
    index = imgs.length - 1;
  }
  img.style.transform = `translateX(${-index * 500}px)`;
  console.log(img);
});
Hi friends, I want to make autoplay image in this slider but setInterval is not working, can you say what is wrong in here? Thank you

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Your function adds an eventlistener but it will only work when there will be an event(which is click in this case)

You can use swiperjs, it has many types of features and framework/library implentations. https://swiperjs.com/swiper-api

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda