const txt = `Watch me as I get typed out before your very eyes using JavaScript's setInterval() function.`; const outputEl = document.getElementById('target-element'); const speed = 50; // Keeps track of character being typed: let i = 0; // Types a new character every 50 milliseconds to outputEl const timerId = setInterval(() => { outputEl.innerHTML += txt.charAt(i); i++; if (i === txt.length) { clearInterval(timerId); } },speed);
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter