Skip to content

Instantly share code, notes, and snippets.

@ramiabraham
Created May 18, 2013 09:34
Show Gist options
  • Save ramiabraham/5603869 to your computer and use it in GitHub Desktop.
Save ramiabraham/5603869 to your computer and use it in GitHub Desktop.
Easy lettering.js setup
// Easy lettering.js
$('.splitWord').children().andSelf().contents().each(function() {
if (this.nodeType == 3) {
$(this).replaceWith(
$(this).text().replace(/(\w)/g, "<span class='char'>$&</span>")
);
}
});
// Adds class,to each letter `.char1`, `.char2`, `.char3`, ...
$('.splitWord').each(function() {
$('span.char', this).each(function(i) {
i = i+1;
$(this).addClass('char' + i);
});
});
// Use in.splitWord.char.char1,2,3etc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment