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