Evitar que HTML feche tag

Viewed 20

Crieii uma função para fazer um efeito de máquina de escrever, o efeito está OK... mas quando ele coloca a tag o próprio html já fecha instantaneamente, evitando que o texto tenha destacado oque eu deixei. Teria alguma forma de evitar que o html feche a tag sozinho ?

Essa é a função:

export default function efeitoMaquinaEscrever(){
  function typeWrite(txt){
    const textoArray = txt.innerHTML.match(/((\<|\<\/)([\w]+)\>)|(\D)/gi);
    txt.innerHTML = '';
    textoArray.forEach((letra,i) => {
      setTimeout(function(){
          txt.innerHTML += letra;
      }, 85 * i)
    })
  }
  const h1 = document.querySelector('.apresentacao-texto');
  typeWrite(h1);
}

Aqui print do resultado no console:

https://i.stack.imgur.com/xCFT1.png

Código do html:

  <section class="apresentacao">
    <div class="container">
      <h1 class="apresentacao-texto">Olá, bem vindo ao meu portfólio.<br>Me chamo <strong>André Luiz</strong> e almejo o<br>cargo de <strong>Estágio Desenvolvedor<br>Web.</strong></h1>
    </div>
  </section>
0 Answers
Related