get Excerpt jQuery - kary4/divituts GitHub Wiki

function maxLength(maxLen)
{
   return function truncateToNearestSpace(idx, text)
   {
       // this may chop in the middle of a word
       var truncated = text.substr(0, maxLen);

       if (/[^\s]$/.test(truncated))
           return truncated.replace(/\s[^\s]+$/, "");
       else
           return truncated.trim();
   }
}

jQuery('.excerpt.entry-summary').each(function(){
    jQuery(this).text(maxLength(20));
});
<script>
jQuery( document ).ready(function() {
jQuery('#left-area > article').each(function(){
    jQuery(this).wrapInner('<p class="article-excerpt"></p>');
    jQuery(this).find('.article-excerpt > *').prependTo(this);
});
}); 
</script> 
⚠️ **GitHub.com Fallback** ⚠️