Luke
0
Q:

typewriter effect css

/*
  Creating a Typing Effect
-----------------------------
1) Add HTML: */
<p id="demo"></p>
<button onclick="typeWriter()">Click me</button>
/* 
2) Add JavaScript: */
var i = 0;
var txt = 'Lorem ipsum typing effect!'; /* The text */
var speed = 50; /* The speed/duration of the effect in milliseconds */

function typeWriter() {
  if (i < txt.length) {
    document.getElementById("demo").innerHTML += txt.charAt(i);
    i++;
    setTimeout(typeWriter, speed);
  }
}
3
Creating a Typing Effect
-----------------------------
1) Add HTML:
Example
<p id="demo"></p>

2) Add JavaScript:
Example
var i = 0;
var txt = 'Lorem ipsum typing effect!'; /* The text */
var speed = 50; /* The speed/duration of the effect in milliseconds */

function typeWriter() {
  if (i < txt.length) {
    document.getElementById("demo").innerHTML += txt.charAt(i);
    i++;
    setTimeout(typeWriter, speed);
  }
}
0

New to Communities?

Join the community