var cutAtSpace = true; // only cut on spaces so words aren't truncated var ellipseWidth = true; // cut if text overflows width (eg looooong word) jQuery(document).ready(function($) { $('.ellipsis').css({'overflow-y':'hidden'}).each(function() { // wrap content so we can measure its height if ($(this).find('.wrapper-ellipsis').size()==0) $(this).wrapInner(''); var wrapper = $(this).find('.wrapper-ellipsis'); var content = wrapper.text().replace().replace(/\s\s+/g,' ').trim(); // check if content overflows height var spliter = cutAtSpace?' ':''; var h1 = $(this).height()*1; var h2 = wrapper.height()*1; if (h2>h1) { var content_split = content.split(spliter); wrapper.html(''); for (var i=0; wrapper.height()*1