javascript - Apply CSS if text exceeds a certain length -
is there way apply css element if text within element exceeds length. instance <p class="foo">123456789</p>
.
then, when text within element exceeds x characters new class applied
<p class="foo text-exceeds-x-chars">12345678910101010101</p>
i'd suggest using addclass
callback function:
$('p.foo').addclass(function() { return $.trim(this.textcontent).length > 10 ? 'text-exceeds-x-chars' : null; });
Comments
Post a Comment