Giter Site home page Giter Site logo

jreadmore's Introduction

jReadMore

This is a simple jQuery plugin that provides the usual read more functionality.

How it works

It adds an element with a link, just right after the element you want to be collapsed. You can click this link to expand or collapse the previous element.

Installation

Include the plugin in your html page. You need to put the following line in your HTML:

    <script src="path/to/your/scipts/folder/jreadmore.min.js"></script>

Usage

To implement the read more functionality to any element, just put the following in a script tag, for the corresponding element.

<script>
    $('.read-more').readMore();
</script>

If you like you can change some of the default options like this:

<script>
    $('.read-more').readMore({
        readMoreHeight: 90
    });
</script>

Options

  • readMoreLinkClass: "read-more__link" The class for the read more link element
  • readMoreText: "Read more" The text to display for collapsed state
  • readLessText: "Read less" The text to display for expanded state
  • readMoreHeight: 75 The height of collapsed state

You can modify collapsed height per element, by setting it in the data-options attribute for each element separately.

<div class="read-more" data-options="90">
    <p>
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc elit metus, facilisis eu odio et, tempor vehicula augue.
        Sed lacinia at orci ut commodo. Mauris mattis tortor quis eros facilisis ullamcorper. Donec venenatis, nulla ac luctus condimentum, justo enim ullamcorper ligula, quis convallis nunc libero at lorem.
        Nam lobortis ligula eu placerat egestas. Praesent erat felis, pellentesque et tristique efficitur, euismod a leo. Donec venenatis, nulla ac luctus condimentum, justo enim ullamcorper ligula, quis convallis nunc libero at lorem.
    </p>
</div>

TODO

  • Use the line-height attribute as the parameter to calculate the element's collapsed height.

The user will have to give the number of lines to show. Furthermore, if the user provide and some units, then they will be used instead.

(e.g. height: 5, to show five lines or height: 120px to show 120px)

jreadmore's People

Contributors

asirokas 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.