Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

249
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda