-
-
Save buzzedword/1095601 to your computer and use it in GitHub Desktop.
Add ellipsis to any text. Choose amount of words to show.
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
String.prototype.ellipsis = function(numOfWords, _text, wordCount ) { | |
_text = this; | |
wordCount = _text.trim().replace(/\s+/g, " ").split(' ').length; | |
_text = _text.trim().split(' '); | |
_text.splice(numOfWords, wordCount, "..."); | |
return _text.join(' '); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment