Created
May 11, 2012 21:39
-
-
Save ptone/2662550 to your computer and use it in GitHub Desktop.
softwrap long strings
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
function softwrap(desc){ | |
var words = desc.split(" "); | |
var newText = ""; | |
for (var i = 0; i < words.length; i++) { | |
var aWord = words[i]; | |
console.log(aWord); | |
if (aWord.length > 20) { | |
aWord = aWord.replace(/(\S{2})/g,"$1​"); | |
} | |
newText += aWord + " "; | |
} | |
return newText; | |
} | |
$('.record_description').each(function(index, value){value.innerHTML=softwrap(value.innerHTML);}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment