Toggle switch
<button class="js-toggle">...</button>
An attribute that points to an element (class or id) that will have the active class switching
<button class="js-toggle" data-toggle-target="#toggleTarget">...</button>
<div id="toggleTarget">Target</div>
data-toggle-link
Elements group declaration. If the attribute is specified, the active class is removed from all elements that belong to the group, and the toggle is added to the target element.
data-toggle-group
Group of the elements
<button class="js-toggle" data-toggle-link="toggleGroup1" data-toggle-target="#toggleGroup1" >...</button>
<button class="js-toggle" data-toggle-link="toggleGroup1" data-toggle-target="#toggleGroup2">...</button>
<div id="toggleGroup1" data-toggle-group="toggleGroup1">Target</div>
<div id="toggleGroup2" data-toggle-group="toggleGroup1">Target</div>
Attribute that sets toggle type
Toggle types:
choice — When clicked, the active class is assigned to the switch and target elements, but it will not be deleted when they are clicked again.
<button class="js-toggle" data-toggle-type="choice" data-toggle-link="toggleGroupChoice" data-toggle-target="#toggleTarget1">...</button>
<button class="js-toggle" data-toggle-type="choice" data-toggle-link="toggleGroupChoice" data-toggle-target="#toggleTarget2">...</button>
<div data-toggle-group="toggleGroupChoice" id="toggleTarget1">Target 1</div>
<div data-toggle-group="toggleGroupChoice" id="toggleTarget2">Target 2</div>
hover — Toggle on hover
<button class="js-toggle" data-toggle-type="hover">...</button>
<button class="js-toggle" data-toggle-type="hover" data-toggle-target="#toggleHoverTarget">...</button>
<div id="toggleHoverTarget">Target</div>
remove — After clicking the toggle switch is deleted.
<button class="js-toggle" data-toggle-type="remove">Remove link</button>
.js-toggle-outside
Remove active class on click to some area out of element
<button class="js-toggle js-toggle-outside"> ... </button>
data-toggle-exceptions
Exceptions - elements, when clicking on which the active class will not be deleted
<button class="js-toggle js-toggle-outside" data-toggle-exceptions="#toggleException"> ... </button>
<div id="toggleException">...</div>