1
I did a typewriter effect with jquery, and I need that effect to take every paragraph. That way I did it applies the effect only to the first paragraph. Follow code for analysis. Can anyone help me? Thanks in advance.
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Maquina de escrever</title>
<style>
body {
background: #0e1013;
}
p{
max-width: 480px;
text-align: center;
margin: 68px auto;
color: #fff;
}
</style>
</head>
<body>
<p>Texto1 - typewriter</p>
<p>Texto1</p>
<p>Texto1</p>
<script>
function typeWriter(elemento) {
const textoArray = elemento.innerHTML.split('');
elemento.innerHTML = '';
console.log(textoArray);
textoArray.forEach((letra, i)=> {
setTimeout(() => {
elemento.innerHTML += letra
}, 95*i)
});
}
const titulo = document.querySelector('p');
typeWriter(titulo);
</script>
</body>
</html>
This code is not jQuery.
– Sam
sam, sorry I had jquery in my head at the time of writing the question, I didn’t even realize.
– Marcos De Barros Azevedo
If you have used jQuery, I can put a suggestion in this format.
– Sam