Press "Enter" to skip to content

jQuery Plugin To Truncate A List Of Inline Blocks | block_ellipsis

jQuery block_ellipsis plugin allows only a certain amount of lines to be displayed from the inline-block elements. Then it displays a Show More (customizable) button.

jquery hide element, onclick show hide div jquery demo, jquery hide element by id, javascript showhide div on click, onclick showhide div jquery demo, jquery hide not working

How to make use of it:

1. Load the jQuery library and jQuery block ellipsis plugin at the bottom of the document.

<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="dist/block_ellipsis.js"></script>

2. Enter a list of items included in the container.

<div class="demo">
  <span>Lorem</span>
  <span>ipsum</span>
  <span>dolor</span>
  <span>sit</span>
  <span>amet</span>
  <span>consectetur</span>
</div>

3. Call the plugin in the container and set the minimum number of lines/blocks you want to display.

$('.demo').block_ellipsis({ 
  lines: 2,
  min_blocks: 5
  // MORE OPTIONS HERE
});

4. Full plugin options with a default value.

$('.demo').block_ellipsis({ 

// Amount of lines you want to display
lines: 1,

// Minimum amount of blocks you want to display (useful for responsive)
min_blocks: 0,

// The HTML to display your 'Show more' clickable element.
// You can either use a string, or a function that will take the number of
// remaining blocks as a parameter
more: function (nb) {
  return '<span class="more">Show ' + nb + ' more</span>';
},

// Insert a space before 'Show more' and 'Show less' blocks.
// This is useful because a space between `inline-block` elements is displayed.
// If your elements are floated, this won't change anything.
space_before_blocks: true,

// The HTML to display your 'Show less' clickable element.
less: '<span class="less">Show less</span>',

// CSS rules to apply once the changes are done (avoids flickering)
css: {
  visibility: 'visible',
  overflow: 'visible'
},

// Enables debug features
debug: false

});

jquery plugin to show/hide block elements, jquery block ellipsis Plugin/Github, hide and show in javascript


See Demo And Download

Official Website(algolia): Click Here

This superior jQuery/javascript plugin is developed by algolia. For extra advanced usage, please go to the official website.

Be First to Comment

    Leave a Reply

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