Succinct: A tiny jQuery plugin for truncating multiple lines of text

by Mike King

Demo

Live Demo Code Repo

How does it work?

Succinct shortens your text to a specified size, and then adds an ellipsis to the end.

Usage

Specify the elements that you would like to truncate as a selector, and then set the size parameter to the amount you would like to see. For example, if you would like to truncate all elements with a specific class, ie. <p class="truncate"> to 120 characters…

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

By default, the plugin truncates text to 240 characters.

Details

  • * Succinct is < 0.5kb minified
  • You’ll need a copy of jQuery to run this plugin
  • If you have any suggestions, comments, or creative insults for my code, add an issue or fork the repo.

The Watercooler

  1. zack

    succinct worked perfectly for me, only downfall, i added “read more” on to my truncation but cannot wrap it in a span or style to separate it’s text color. Is there a way to achieve this? I would love the ability to add a style or html span

    Reply

Speak your Mind

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

In the words of Chaka Khan: Tell Me Something Good!




×