1/*
2 Creating a Typing Effect
3-----------------------------
41) Add HTML: */
5<p id="demo"></p>
6<button onclick="typeWriter()">Click me</button>
7/*
82) Add JavaScript: */
9var i = 0;
10var txt = 'Lorem ipsum typing effect!'; /* The text */
11var speed = 50; /* The speed/duration of the effect in milliseconds */
12
13function typeWriter() {
14 if (i < txt.length) {
15 document.getElementById("demo").innerHTML += txt.charAt(i);
16 i++;
17 setTimeout(typeWriter, speed);
18 }
19}
20