🔔 Alert..!! Get 2 Month Free Cloud Hosting With $200 Bonus From Digital Ocean ACTIVATE DEAL

Trunc.js is a dead simple (less than 1kb) jQuery text truncation plugin that truncates text to a specified number of characters with an ellipsis.

Text-Truncating

Documentation

jQuery truncate text

The plugin is used to truncate text. It also adds hellip to the end of string. Click on hellip (...) allows you to see the whole text.

Code Example

To truncate a text inside the element use next method:

$('p').trunc(7);

The paragraph before using method:

<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. In ad eveniet, harum non. Quaerat voluptatem   totam explicabo repellat cumque rerum nesciunt, quia in, qui nostrum, recusandae eligendi sequi. Nihil,   quas.</p>

The paragraph after using method:

<p>Lorem ...</p>

The length of hellip and white spases are also taken into account.

It is possible to see the whole text after clicking on hellip (...):

Example

Argument

The argument must be positive integer number and greater than zero. If the argument is bigger than text length, method is doing nothing.

One element is mandatory (used to show the hellip)


You May Also Like