Skip to content

Instantly share code, notes, and snippets.

@alissa-maria
Last active December 5, 2023 13:41
Show Gist options
  • Select an option

  • Save alissa-maria/ed2062bd6546bb49724b0f5a3c029fd9 to your computer and use it in GitHub Desktop.

Select an option

Save alissa-maria/ed2062bd6546bb49724b0f5a3c029fd9 to your computer and use it in GitHub Desktop.
Simplified version of typewriter effect from https://github.com/alissa-maria/ceramic
const textElement = document.getElementById('fetch');
const originalText = textElement.textContent.trim();
textElement.textContent = '';
let index = 0;
function typeNextCharacter() {
textElement.textContent += originalText[index];
index++;
if (index < originalText.length) {
setTimeout(typeNextCharacter, 40);
}
}
typeNextCharacter();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment