Created
December 14, 2015 14:04
-
-
Save eMahtab/ea6a510fda7b49a7ad64 to your computer and use it in GitHub Desktop.
JavaScript Typing Text 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
<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