Created
September 13, 2011 17:54
-
-
Save andredublin/1214505 to your computer and use it in GitHub Desktop.
Find text of html element, replace with modified text
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
function newText(obj, text, classy) { | |
var hLen = text.length, | |
firstIdx = text.indexOf(' '), | |
startStr = text.slice(0, firstIdx), | |
endStr = text.slice(firstIdx, hLen), | |
newStr = startStr + '<span class="'+classy+'">' + endStr + '</span>'; | |
$(obj).html(newStr); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment