Mobile-compatible Read More/Read Less Plugin - jQuery Showmore

File Size: 25 KB
Views Total: 2295
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   
Mobile-compatible Read More/Read Less Plugin - jQuery Showmore

Showmore is a lightweight, mobile-compatible jQuery read more/read less plugin for long web content.

The plugin limits your web content and creates custom show more/show less buttons to toggle the content when it exceeds a certain height.

Smooth open/close animations are based on CSS3 transitions.

How to use it:

1. Insert the minified version of the jQuery Showmore plugin after jQuery.

<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" 
        integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" 
        crossorigin="anonymous">
</script>
<script src="dist/jquery.showmore.min.js"></script>

2. Call the function on the target container and specify the closedHeight you want to use (Default: 100px).

$('#container').showmore({
  closedHeight: 50,
  buttonTextMore: 'Show more'
});

3. Customize the read more/read less buttons.

$('#container').showmore({
  buttonTextMore: 'show more',
  buttonTextLess: 'show less',
  buttonCssClass: 'showmore-button'
});

4. Customize animation speed in seconds.

$('#container').showmore({
  animationSpeed: 0.5
});

5. Make this plugin work only at a certain screen width (Default: 0).

$('#container').showmore({
  onlyWithWindowMaxWidth: 768
});

6. Set the offset in pixels.

$('#container').showmore({
  openHeightOffset: 0
});

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