Skip to content

Instantly share code, notes, and snippets.

@sushat4692
Created June 18, 2019 03:24
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 sushat4692/6c3e0d463a1a4b1ec76e378111084207 to your computer and use it in GitHub Desktop.
Save sushat4692/6c3e0d463a1a4b1ec76e378111084207 to your computer and use it in GitHub Desktop.
function separateText($parent, tagName) {
$parent.children().addBack().contents().each(function() {
if (this.nodeType == 3) {
$(this).replaceWith($(this).text().replace(/(\S)/g, '<'+tagName+'>$1</'+tagName+'>'));
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment