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

191
Visualizações
How to set time gap between each iteration of foreach() in js

I am trying to get a typing effect for multiple lines. I want that my next for each iteration should run after the previous one has been executed. Is there a way to do that

HTML-

<body>
    <div class="intro">
        <p class="intro-text" style="display: none;">Hi</p>
        <p class="intro-text" style="display: none;">This is Yash Verdhan Gupta</p>
        <p class="intro-text" style="display: none;">And i am a ....</p>
    </div>
</body>

JS

const introtext = document.querySelectorAll('.intro-text')

introtext.forEach((element) => {
    var text = element.innerText;
    var textlenght = text.length;
    element.style.display = 'block';
    var newtext = '';
    var i = 0;
    setInterval(writer, 200)
    function writer() {
        element.innerText = Newtext();
    }
    function Newtext() {
        if (i < textlenght) {
            newtext = newtext + text.charAt(i);
            i++
        }
        return newtext
    }
})```
about 4 years ago · Juan Pablo Isaza
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