Truncate Multi-line Text With jQuery - readMore

Truncate Multi-line Text With jQuery - readMore
File Size: 3.37 KB
Views Total:
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

readMore is a lightweight, cross-browser jQuery multi-line text truncation plugin that allows to excerpt your long text content depending on number of lines.

See also:

How to use it:

1. Download and put the main JavaScript file readMore.jquery.js after you've loaded jQuery library.

<script src="//code.jquery.com/jquery.min.js"></script>
<script src="readMore.jquery.js"></script>

2. Call the function on the target text container and done. Characters those exceed that number of lines (default: 5) are truncated with '...' at the end.

<p>Donec egestas ac nisl in faucibus. Curabitur pretium erat id neque aliquam pharetra. Praesent nulla purus, consequat nec libero sit amet, lobortis semper orci. Aliquam urna sapien, scelerisque ac leo nec, interdum vehicula libero. Aliquam sed sapien purus. Sed posuere massa ac ultrices pharetra. Fusce tincidunt risus vel laoreet sollicitudin. Suspendisse mollis, purus non finibus dapibus, sapien est imperdiet dui, ac vehicula tortor ligula ac augue. Aliquam sed ante et ligula hendrerit dignissim sed ut ligula. Duis ac lectus faucibus, aliquet eros sed, hendrerit mi. Donec sed justo purus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nam eu enim enim. Nulla rhoncus lorem nec mauris dapibus commodo.</p>
$("p").readMore();

3. Specify the number of lines to truncate.

$("p").readMore({
  numberOfLines: 7
});

4. Customize the ellipsis character.

$("p").readMore({
  endingTag : '&hellip;'
});

This awesome jQuery plugin is developed by tommitomov. For more Advanced Usages, please check the demo page or visit the official website.