Created
July 26, 2024 02:18
-
-
Save zakariabinsaifullah/6d9cbc2c8c15aa07343b2013de912e9c to your computer and use it in GitHub Desktop.
Vanilla Js typing effect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<body> | |
<h1>Typewriter</h1> | |
<button onclick="typeWriter()">Click me</button> | |
<p id="demo"></p> | |
<script> | |
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); | |
i++; | |
setTimeout(typeWriter, speed); | |
} | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment