Skip to content

Instantly share code, notes, and snippets.

@baras
Created October 14, 2018 05:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baras/def87a9d32ca8aad07628e606af2a1ad to your computer and use it in GitHub Desktop.
Save baras/def87a9d32ca8aad07628e606af2a1ad to your computer and use it in GitHub Desktop.
/**
* Wrap each letter of text in the given element in a span tag.
*/
$.fn.lettering = function () {
this.each(function (index) {
var elem = $(this),
characters = elem.text().split("");
elem.empty();
$.each(characters, function (i, el) {
elem.append('<span>' + el + "</span");
});
});
return this;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment