businessdad icon

fpvracingproducts.com - Grid fixed size

businessdad | PRO | 08/16/16 11:19:27 PM UTC | 0 ⭐ | 912 👁️ | Never ⏰ | []
JavaScript |

470 B

|

None

|

0 👍

/

0 👎

/* CSS */
.short-description p {
  height: 3em;
}
 
/* JavaScript */
jQuery(document).ready(function($) {
  function shorten_text(selector) {
    $(selector).each(function() {
      var $elem = $(this);
      var wordArray = $elem.html().split(' ');
  
      while($elem.prop('scrollHeight') > $elem.prop('offsetHeight')) {
        wordArray.pop();
        $elem.html(wordArray.join(' ') + '...');
      }
    });
  }
  shorten_text('.short-description p');
});

Comments