Code Monkey home page Code Monkey logo

jquery-collapse's Introduction

jQuery Collapse

A lightweight plugin for enabling expandable/collapsible content.

  • Packaged with cookie support (yum yum!)
  • Lightweight (655 bytes minified and gzipped)
  • ARIA compliant

Enjoy!

Usage

HTML:

<div id="demo">
    <h3>Fruits</h3>
    <ul>
        <li>Apple</li>
        <li>Pear</li>
        <li>Orange</li>
    </ul>
    <h3>Info</h3>
    <div>
        <p>You can use any container you like (in this case a div)</p>
    </div>
</div>

JavaScript:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script src="jquery.collapse.js"></script>
<script src="jquery.cookie.js"></script> <!-- If you want cookie support -->
<script>
$(function() {
    $("#demo").collapse();
});
</script>

Note: If you're using the plugin on different pages on the same domain, you'll have to have a unique cookie name for each instance to avoid conflict. Use the "cookie" option to set a unique cookie name.

Options

  • show (function) : Custom function for showing content (default: function(){ this.show() })
  • hide (function) : Custom function for hiding content (default: function(){ this.hide() })
  • head (string) : Elements for clickable headings (default: "h3")
  • group (string): Elements containing the collapsable content (default: "ul, div")
  • cookieName (string) : Name of cookie used in the plugin. (default: "collapse")

Browser Support

Probably works in most modern browsers, but only tested in: Safari, Chrome, IE6+, Firefox3+, Opera10+

Google Chrome does not work with cookies if run locally (i.e file://) For more details: http://code.google.com/p/chromium/issues/detail?id=535

jquery-collapse's People

Contributors

danielstocks avatar stanislaw avatar

Stargazers

 avatar

Watchers

 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.