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

196
Vistas
Change the method of array for start and stop timing to sequently

I just need to change the method of array to sequently for start and stop timing. I need to be like this :

start"word1, "start"word2", start"word3", start"word4"

const timings = [
  { start: 0, stop: 1000 },
  { start: 1000, stop: 2000 },
  { start: 2000, stop: 5000 },
  { start: 5000, stop: 10000 }
]

const durations = timings.map(timing => timing.stop - timing.start                             
)

const container = document.body;
const childArray = [...container.children]; // To use array methods


childArray.forEach((el, i) => {
  el.onclick = () => {
    el.classList.toggle('highlight');
    
    nextWord = childArray[i + 1];
    if (!nextWord) return // Last word
    
    setTimeout(() => {
      el.classList.toggle('highlight');
      nextWord.click();
    }, durations[i])
  }
})
.highlight {
  background-color: yellow;
}
<!DOCTYPE html>
<html>
<body>
  <span>word1</span>
  <span>word2</span>
  <span>word3</span>
  <span>word4</span>
</body>
</html>

about 4 years ago · Santiago Gelvez
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