Swaps a class or list of classes from an element for another class or list of classes.
- Calling Convention:
_.Class.toggle(Element, [String || Array])
- The element to remove classes from
- A string containing a single class
- An array of class strings
- True if class or classes were added
- False if class or classes were removed
Example #1 -- String
<p id="test" class="one"></p>
var p = document.getElementById('test'); _.Class.toggle(p, 'two'); // p#test now has class 'two' _.Class.toggle(p, 'one'); // p#test no longer has class 'one' since it started out with it.
While this does accept arrays you should be aware that if any array entry is removed, NONE will be set! Values will only be set if none are removed. Whether this should be considered the correct behavior or if steps should be taken to be a literal toggle is still under debate, so for now do not rely on the Array behaviors as it may change.