Search code examples
jqueryhyperlinktoggle

jQuery Collapsible Plugin: How to toggle Open all/Close all


http://github.com/juven14/Collapsible http://www.snyderplace.com/demos/collapsible.html

Instead of the two links "Open All" and "Close All" I want only one link toggling.


Solution

  • The jquery.collapsible.js API comes with a toggle method:

    These are the methods available from the plugin:

    • cssClose - class assigned when closed
    • collapsed - returns 'true' if element is collapsed
    • toggle - toggle collapsible state
    • open - open a collapsible
    • close - close a collapsible

    -Via "Plugin Methods" on the page OP provided

    Mimicking the style found on the demo page:

    function toggle() {
        $('.page_collapsible').collapsible('toggle');
    }
    
    $('#toggle').click(function(event) {
        event.preventDefault();
        toggle();
    });