Skip to content

Instantly share code, notes, and snippets.

@shanejdonnelly
Created December 5, 2013 16:12
Show Gist options
  • Save shanejdonnelly/7808207 to your computer and use it in GitHub Desktop.
Save shanejdonnelly/7808207 to your computer and use it in GitHub Desktop.
$.fn.teletype = function(opts){
var $this = this,
defaults = {
animDelay: 50
},
settings = $.extend(defaults, opts);
$.each(settings.text.split(''), function(i, letter){
setTimeout(function(){
$this.html($this.html() + letter);
}, settings.animDelay * i);
});
};
//To use:
$('#container').teletype({
animDelay: 100, // the bigger the number the slower the typing
text: 'Text to be typed here.'
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment