Created
May 18, 2013 09:34
-
-
Save ramiabraham/5603869 to your computer and use it in GitHub Desktop.
Easy lettering.js setup
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
// 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