Home

# Library goog.dom.classes

Function Summary
| `add(?Node element, (string|undefined) var_args) ⇒ boolean` Adds a class or classes to an element. Does not add multiples of class names.

`addRemove(?Node element, (Array.<string>|null|string) classesToRemove, (Array.<string>|null|string) classesToAdd)`

Adds zero or more classes to an element and removes zero or more as a single operation. Unlike calling {@link goog.dom.classes.add} and {@link goog.dom.classes.remove} separately, this is more efficient as it only parses the class property once. If a class is in both the remove and add lists, it will be added. Thus, you can use this instead of {@link goog.dom.classes.swap} when you have more than two class names that you want to swap.

| `add_(?Array.<string> classes, ?Array.<string> args) ⇒ boolean` Helper method for {@link goog.dom.classes.add} and {@link goog.dom.classes.addRemove}. Adds one or more classes to the supplied classes array.
| `enable(?Node element, string className, boolean enabled)` Adds or removes a class depending on the enabled argument.
| `get(?Node element) ⇒ ?Array` Gets an array of class names on an element
| `has(?Node element, string className) ⇒ boolean` Returns true if an element has a class.
| `remove(?Node element, (string|undefined) var_args) ⇒ boolean` Removes a class or classes from an element.
| `remove_(?Array.<string> classes, ?Array.<string> args) ⇒ boolean` Helper method for {@link goog.dom.classes.remove} and {@link goog.dom.classes.addRemove}. Removes one or more classes from the supplied classes array.
| `set(?Node element, string className)` Sets the entire class name of an element.
| `swap(?Node element, string fromClass, string toClass) ⇒ boolean` Switches a class on an element from one to another without disturbing other classes. If the fromClass isn't removed, the toClass won't be added.
| `toggle(?Node element, string className) ⇒ boolean` Removes a class if an element has it, and adds it the element doesn't have it. Won't affect other classes on the node.