Last active
August 29, 2015 14:06
-
-
Save shapkarin/0fb50100de3a8c8f3e64 to your computer and use it in GitHub Desktop.
Typewriter Effect Implementations (with JQuery)
This file contains 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
//this solution is much better | |
function typewriter(text, name){ | |
var input = form.find('input[name="'+ name + '"]').val('')[0], | |
s = text.split('').reverse(), | |
len = s.length-1, | |
var initInterval = setInterval(function(){ | |
if( s.length ){ | |
var c = s.pop(); | |
input.value += c; | |
} | |
else clearInterval(initInterval); | |
},150); | |
} |
This file contains 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
//hmm has bugs if change tab while writing into div | |
function typewriter(text, name) { | |
var input = form.find('input[name="'+ name + '"]'); | |
$.each(text.split(''), function(i, letter){ | |
setTimeout(function(){ | |
input.val(input.val() + letter); | |
}, 70*i); | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment