Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

TYPING TEXT USING JS

document.addEventListener("DOMContentLoaded", function () {
  let letter = 0;
  const text = "Lorem ipsum dolor sit consectetur.";
  function typeText() {
    if (letter < text.length) {
      document.getElementById("type-js").innerHTML += text.charAt(letter);
      letter++;
      let speed = Math.floor(Math.random() * 150) + 50;
      setTimeout(typeText, speed);
    }
  }
  typeText();
});Code language: JavaScript (javascript)
Source by w3collective.com #
 
PREVIOUS NEXT
Tagged: #TYPING #TEXT #USING #JS
ADD COMMENT
Topic
Name
6+6 =