Display text paragraphs with animation effect
by Osama Qassar
HTML
<p id="typewriter"></p>
<script>
const text = "This is a simple paragraph that appears word by word.";
const words = text.split(" ");
const element = document.getElementById("typewriter");
let index = 0;
function typeWord() {
if (index < words.length) {
element.innerHTML += words[index] + " ";
index++;
setTimeout(typeWord, 100); // adjust typing speed here (ms)
}
}
typeWord();
</script>