Skip to content

Instantly share code, notes, and snippets.

@ijones922
Created November 15, 2013 22:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ijones922/7492837 to your computer and use it in GitHub Desktop.
Save ijones922/7492837 to your computer and use it in GitHub Desktop.
ellipsis
/* elipsify any text you want to truncate. Simply use .text(cut([n])) then .append() to add in any character(s) you want after. ex: ('...')*/
function cut(n) {
return function textCutter(i, text) {
var short = text.substr(0, n);
if (/^\S/.test(text.substr(n)))
return short.replace(/\s+\S*$/, "");
return short;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment