showing results for - "typing text using js"
Cain
24 Nov 2016
1document.addEventListener("DOMContentLoaded", function () {
2  let letter = 0;
3  const text = "Lorem ipsum dolor sit consectetur.";
4  function typeText() {
5    if (letter < text.length) {
6      document.getElementById("type-js").innerHTML += text.charAt(letter);
7      letter++;
8      let speed = Math.floor(Math.random() * 150) + 50;
9      setTimeout(typeText, speed);
10    }
11  }
12  typeText();
13});Code language: JavaScript (javascript)
queries leading to this page
typing text jstyping text using js