Truncate a string in jQuery without cutting off word
If you'd like to display a preview of some text without cutting ending the preview in the middle of a word you can use the following snippet: jQuery.trim("This is a nice long sentence from which a preview will be created).substring(