0
The thing is, I need a sentence to appear as if it were typed on the screen, and after the first sentence appears completely, a new one should appear in the same way as the previous one. The part about showing the text has already been done, but I don’t know how to implement the phrase replacement part. Does anyone have any idea how this can be done?
function typeWriter(elemento) {
const textoArray = elemento.innerHTML.split('');
elemento.innerHTML = '';
textoArray.forEach((letra, i) => {
setTimeout(() => elemento.innerHTML += letra, 75 * i);
});
}
const titulo = document.querySelector('.fundo-roxo');
typeWriter(titulo);
<div class="col-xs-12 col-md-12">
<h1 class="titulo-linha-1"><span class="fundo-roxo">Texto 1.</span></h1>
</div>