Skip to content

Instantly share code, notes, and snippets.

@elclanrs
Created October 5, 2012 22:19
Show Gist options
  • Save elclanrs/3842779 to your computer and use it in GitHub Desktop.
Save elclanrs/3842779 to your computer and use it in GitHub Desktop.
jquery.animateText
$.fn.animateText = function(delay, klass) {
var text = this.text();
var letters = text.split('');
return this.each(function(){
var $this = $(this);
$this.html(text.replace(/./g, '<span class="letter">$&</span>'));
$this.find('span.letter').each(function(i, el){
setTimeout(function(){ $(el).addClass(klass); }, delay * i);
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment