Skip to content

Instantly share code, notes, and snippets.

@zakariabinsaifullah
Created July 26, 2024 02:18
Show Gist options
  • Save zakariabinsaifullah/6d9cbc2c8c15aa07343b2013de912e9c to your computer and use it in GitHub Desktop.
Save zakariabinsaifullah/6d9cbc2c8c15aa07343b2013de912e9c to your computer and use it in GitHub Desktop.
Vanilla Js typing effect
<!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