Created
November 3, 2012 23:42
-
-
Save bloodyowl/4009348 to your computer and use it in GitHub Desktop.
First Word Wrapper (Craft.js)
This file contains hidden or 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
Craft.extend(DOM.prototype, { | |
wrapFirstWord : function(tag){ | |
var element = this, | |
text = element.get("innerHTML"); | |
return element.empty().insert(text.replace(/^([\w]*\s)/,"<" + tag + ">$1</" + tag + ">")) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment