Typwriter effect on text using java

i am trying to add typewriter animation to my html text as soon as the url loads, using the code below. Please check why this might not be working.

  <!DOCTYPE html>
    <p onload="typeWriter()" id="demo"></p>
    p   {
      color: Black;
      font-family: arial;
    var i = 0;
    var txt = 'Lorem ipsum dummy text blabla.';
    var speed = 50;
    function typeWriter() {
      if (i < txt.length) {
        document.getElementById("demo").innerHTML += txt.charAt(i);
        setTimeout(typeWriter, speed);

56 thoughts on “Typwriter effect on text using java”

Leave a Comment