Skip to content

Instantly share code, notes, and snippets.

@sealucky7
Created March 17, 2017 08:54
Show Gist options
  • Select an option

  • Save sealucky7/0dbd794029e90d3cb2cf09e799b6138a to your computer and use it in GitHub Desktop.

Select an option

Save sealucky7/0dbd794029e90d3cb2cf09e799b6138a to your computer and use it in GitHub Desktop.
cutLongText
function cutLongText() {
var elem, size, text;
size = 120;
elem = $('your classes or id');
$.each(elem,function(){
text = $(this).html();
if (text.length > size) {text = text.slice(0, size);}
$(this).html(text + '...');
});
console.log(elem);
}
cutLongText();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment