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

255
Vistas
How to fix setTimeout() when appending to document

So I have a thing to show when a user is typing in my website but I want the typing... to show the dots slower rather than instantly right now I have my current code which works perfectly which is great just it sends the .. and turns it into ... instantly but I'd like to add a like timeout somehow.

var countTyping = 0;

function typingAnimation() {
let items = ['.', '..', '...'];
//return items[Math.floor(Math.random() * items.length)];
//return items[countTyping]; dont use
if (countTyping < 2) {//if the count is less than 2
  countTyping++
  return items[countTyping]
}
  else {
    countTyping = 0
    return items[countTyping];
  }
}

later on I have

'user is typing' + typingAnimation()

in my code which is appended to the document so I can't use a setTimeout(typingAnimation, 1000) or anything or it would show random numbers.

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

0

My fix was to add more elements to the array but there are lot more options but this is easiest and quick find for me.

let items = ['.', '.', '..', '..', '...', '...'];
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