JSFiddle - React, Tailwind, and code Playground
HTML
<ul>
<li class="latestnewsfooterCol">tests this for so many words</li>
<li class="latestnewsfooterCol"><p>a very long text blah blah</p></li>
</ul>
JavaScript
var maxNum = function($elie, num) {
var $this;
$elie.each(function() {
$this = $(this);
$this.text( $this.text().split(/\s+/).slice(0,num).join(" "));
});
}
$(function() {
maxNum($('li.latestnewsfooterCol'),5);
});