Coder Social home page Coder Social logo

readmore-readless's Introduction

readmore-readless

A jquery plugin for Read more and Read less functionality

Consider an HTML div like following:

<div id="readMoreReadLess">
    <ul class="item">
        <li>Item 1</li>
        <li class="details">Details of Item 1</li>
    </ul>

    <ul class="item">
        <li>Item 2</li>
        <li class="details">Details of Item 2</li>
    </ul>

    <ul class="item">
        <li>Item 3</li>
        <li class="details">Details of Item 3</li>
    </ul>
</div>

We can achieve the Read more and Read less functionality by simple code.

Usage 1: Use the plugin in default mode. There will be two items in the summary and on clicking the Read more link, all items would be displayed.

$("#readMoreReadLess").readMoreReadLess();

Usage 2: Setting the items present in the summary as 1. Only one item would appear in the summary. Use the plugin with items in summary set to 1

$("#readMoreReadLess").readMoreReadLess({
      itemInSummary: 1
});

Usage 3: Customising the Read More links with user defined text and css class.

$("#readMoreReadLess").readMoreReadLess({
        readMoreText: 'Show more items ...',
        readLessText: 'Show fewer items ...',
        readMoreClass:'button',
        readLessClass:'button'
});

options is an optional javascript object with parameters explained below.

Options

  • itemClass A class name which is present on each item. default: 'item'

  • itemInSummary The number of items that should appear in the summary view. default: 2

  • readMoreClass A class name which would be applied to Read More link. default: 'read-more'

  • readLessClass A class name which would be applied to Read less link. default: 'read-less'

  • readMoreText The text for the link representing "Read more" default: 'Read more >> '

  • readLessText The text for the link representing "Read less" default: 'Read less << '


This software is made available under the open source MIT License. © 2013

readmore-readless's People

Watchers

VitalyS avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.