This repository is a mirror of the component module matthewmueller/switcher. It has been modified to work with NPM+Browserify. You can install it using the command npm install npmcomponent/matthewmueller-switcher
. Please do not open issues or send pull requests against this repo. If you have issues with this repo, report it to npmcomponent.
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