Skip to content

Instantly share code, notes, and snippets.

@eMahtab
Created December 14, 2015 14:04
Show Gist options
  • Save eMahtab/ea6a510fda7b49a7ad64 to your computer and use it in GitHub Desktop.
Save eMahtab/ea6a510fda7b49a7ad64 to your computer and use it in GitHub Desktop.
JavaScript Typing Text Effect
<html>
<head>
<style>
#myTypingText {
background-color:#000;
width:700px;
height:120px;
padding:12px;
color:#FFF;
font-family:Arial, Helvetica, sans-serif;
font-size:16px;
line-height:1.5em;
}
</style>
</head>
<body>
<div id="myTypingText"></div>
<script>
var myString = " Life becomes awesome when you know it is. Thinking small will make you doing small which will end up dreaming small.";
var myArray = myString.split("");
var loopTimer;
function frameLooper() {
if(myArray.length > 0) {
document.getElementById("myTypingText").innerHTML += myArray.shift();
} else {
clearTimeout(loopTimer);
return false;
}
loopTimer = setTimeout('frameLooper()',70);
}
frameLooper();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment