Extremely Lightweight jQuery Multiline Text Truncating Plugin - Succinct

File Size: 5.52KB
Views Total: 1912
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   
Extremely Lightweight jQuery Multiline Text Truncating Plugin - Succinct

Succinct is a super lightweight (~0.6kb minified) jQuery plugin that allows you to shortens your text to a specified size, and then adds an ellipsis (or custom characters) to the end. Good for displaying a summary or description of a post with the "..." text at the end. The plugin works in modern and old browsers which don't support CSS3 text truncation and ellipses.

How to use it:

1. Load the jQuery javascript library and jQuery succinct plugin at the bottom of your page

<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script src="jQuery.succinct.js"></script>

2. Add a class to your text paragraph

<p class="demo">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque egestas rhoncus mi, consequat vulputate augue tincidunt in. Maecenas quam ligula, aliquam consectetur aliquet vitae, posuere vitae ipsum. Curabitur sed purus vehicula erat interdum molestie. Nullam venenatis at lacus nec facilisis. Phasellus convallis ante malesuada odio condimentum feugiat. Fusce eu auctor tellus, nec vehicula lectus. Duis libero purus, ullamcorper eu malesuada at, consectetur sed elit. Mauris viverra nunc at ullamcorper molestie. Fusce turpis mi, semper eu consectetur at, rhoncus quis tellus.
</p>

3. Call the plugin with options

<script>
$(function(){
$('.demo').succinct({
size: 240
});
});
</script>

4. All the opitons

<script>
$(function(){
$('.truncate').succinct({
size: 240,
omission: '...',
ignore: true // removes the set of 32 ASCII special characters at the end of words
});
});
</script>

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