Intro

open-toggle is a jQuery plugin that makes sure that only one element has (user-defined)open class at a time amongst the selected elements.

Demo

Basic
You can even have a default opened element by just adding open or user-defined class to that element!

Usage

Download the plugin and add it to the page.


<script src="/path/to/jquery.open-toggle.min.js"></script>
            

Add some HTML elements to the page.


Add the following script at the end of the <body> tag.


<script>
  $(document).ready(function(){
    $(".open-toggle").openToggle();
  });
</script>
            

Thats it! This plugin will make sure that only one element has open class.

Options

$( selector ).openToggle( <className> );

selector
Defines which element are to be considered by this plugin.

className - Optional. Default: open
Defines the class name that is to be added to element when it is clicked(opened).