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.

Related Posts

Cookie-Consent-Using-Bootstrap

How to Create a Simple Cookie Banner Consent Using Bootstrap 4

Cookie Consent Popup Javascript – Quick and simple tutorial for creating a simple Bootstrap cookie banner. If you have a website or blog with people visiting or…

Create-HTML-Terminals

Create Custom HTML Terminals With Pure JavaScript | shell.js

Custom HTML Terminals is A JavaScript library to create HTML terminals on web pages. The shell js JavaScript library offers a straightforward method to create Ubuntu, OS X,…

Bootstrap-Alert-Bootbox

Bootstrap Alert, Confirm, and Flexible Dialog Boxes | Bootbox

Bootbox.js is a small JavaScript library that allows you to create programming dialogs using Bootstrap templates, without having to worry about creating, managing, or removing any required…

Slider-fg-carousel

An Accessible Touch-enabled Slider Web Component | fg-carousel

fg-carousel Slider – A simple & modern slider web component to create versatile, accessible, touch-enabled picture carousels utilizing CSS scroll snap, Custom Element, and Intersection Observer API….

Tags-Input-Component

A Lightweight and Efficient Tags Input Component in Vanilla JS | tagify

tagify transforms an input field or textarea into a tags component, in an easy and customizable way, with great performance and a small code footprint, full of…

copy-to-clipboard-javascript

A Lightweight Library to Copy Text to Clipboard | CopyJS

CopyJS is a lightweight JavaScript library that allows you to copy plain text or HTML content to the clipboard. Must Read: Tiny Library for Copy Text In…