A repository of over 1000 quality jQuery plugins

jQuery Collapser

Collapser is a jQuery Hide & Reveal plugin.

Created by Vaakash

Collapser is a small and useful jQuery plugin for collapsing/truncating an element text by words, characters and lines with a flexible API. It is an all in one plugin with multiple functionalities to truncate a paragraph or any element as desired.

Not what you're looking for? Click here to view more Hide & Reveal jQuery plugins

jQuery Collapser

Collapser is a small and useful jQuery plugin for collapsing/truncating an element text by words, characters and lines with a flexible API. It is an all in one plugin with multiple functionalities to truncate a paragraph or any element as desired.

Check out the working demo - Homepage

Why it is needed ?

Collapser is really useful to truncate long text in terms of characters, words or lines. It can also toggle the visibility elements. Hence 4 modes of operation in one plugin. Some practical examples are also demostrated.

Features

  • Four modes of operation
    • Truncate text by characters
    • Truncate text by words
    • Truncate text by lines
    • Show/hide element
  • HTML content present in the elements are preserved during the operation.
  • Simple and flexible API for using in varied applications.
  • Display remaining string count in the show/hide button.
  • No complicated syntax or alterations required, can be used readily.
  • Light weight only 4KB after minification.
  • Works in all browsers. Tested till IE 7 and it works !

Syntax

HTML:

<p class="myElement">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p>

JavaScript:

$('.myElement').collapser({
    mode: 'words',
    truncate: 20
});

Output:

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut ... [Show text]

More demos

Documentation

Click here to see the docs of this plugin.

Requirements

  • jQuery 1.7+ thats it ..

License

Copyright (c) 2014 Aakash Chakravarthy, released under the MIT License.



You might also like these other Hide & Reveal jQuery Plugins

  • jQuery Stickout

    Sticky headers that hide on scroll-down but reveal on scroll-up

  • IntelliMenu

    jQuery sticky menu plugin that hides and reveals itself intelligently

  • JQuery Spoiler Project

    A simple project that uses Jquery to hide/reveal spoilers through buttons

License:

The MIT License (MIT)