Switch between elements using a class. Ensures that you can only select one element at a time.
<ul>
<li>hi</li>
<li>hello</li>
<li>whats up</li>
<li>whatever</li>
<li>cool</li>
</ul>
<div id="another">another item</div>
var Switch = require('switcher');
var switcher = Switch(),
items = document.querySelectorAll('li');
for (var i = 0, len = items.length; i < len; i++) {
switcher.add(items[i]);
};
switcher.add(another);
$ component install matthewmueller/switcher
Initialize a switcher with a given className
. Defaults to .is-selected
.
Add an element to the switcher with an optional fn
.
Remove an element from the switcher and unbinds the click event.
MIT