Truncate Text To Fit Its Container's Height - LC Text Shortener

Truncate Text To Fit Its Container's Height - LC Text Shortener
File Size: 8.37 KB
Views Total: 95
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

Just another jQuery text truncation plugin for shortening text based on its container's height or a fixed height value.

See Also:

How to use it:

1. Load the LC Text Shortener plugin's files after jQuery library and we're ready to go.

<script src="/path/to/cdn/jquery.slim.min.js"></script>
<script src="/path/to/lc_text_shortener.min.js"></script>

2. Call the function on the container whose text will be dynamically truncated based on its height.

<section id="shortened_txt">
  Text Block Here
</section>
$(function(){
  $('#shortened_txt').lc_txt_shortener();
});

3. Specify the character(s) displayed at the end of the text after it has been truncated.

$(function(){
  $('#shortened_txt').lc_txt_shortener('[..]');
});

4. Truncate the text to a specific height instead (300px in this example).

$(function(){
  $('#shortened_txt').lc_txt_shortener('[..]', 300);
});

5. Determine which HTML tags have to be maintained during shortening.

$(function(){
  $('#shortened_txt').lc_txt_shortener('[..]', 300, 'strong, a , em');
});

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