dom.classlist

Classes


Public Protected Private

Global Functions

goog.dom.classlist.add(elementclassName)
Adds a class to an element. Does not add multiples of class names. This method may throw a DOM exception for an invalid or empty class name if DOMTokenList is used.
Arguments:
element : Element
DOM node to add class to.
className : string
Class name to add.
code »
goog.dom.classlist.addAll(elementclassesToAdd)
Convenience method to add a number of class names at once.
Arguments:
element : Element
The element to which to add classes.
classesToAdd : goog.array.ArrayLike.<string>
An array-like object containing a collection of class names to add to the element. This method may throw a DOM exception if classesToAdd contains invalid or empty class names.
code »
goog.dom.classlist.addRemove(elementclassToRemoveclassToAdd)
Adds and removes a class of an element. Unlike goog.dom.classlist.swap, this method adds the classToAdd regardless of whether the classToRemove was present and had been removed. This method may throw a DOM exception if the class names are empty or invalid.
Arguments:
element : Element
DOM node to swap classes on.
classToRemove : string
Class to remove.
classToAdd : string
Class to add.
code »
goog.dom.classlist.contains(elementclassName) boolean
Returns true if an element has a class. This method may throw a DOM exception for an invalid or empty class name if DOMTokenList is used.
Arguments:
element : Element
DOM node to test.
className : string
Class name to test for.
Returns: boolean  Whether element has the class.
code »
goog.dom.classlist.enable(elementclassNameenabled)
Adds or removes a class depending on the enabled argument. This method may throw a DOM exception for an invalid or empty class name if DOMTokenList is used.
Arguments:
element : Element
DOM node to add or remove the class on.
className : string
Class name to add or remove.
enabled : boolean
Whether to add or remove the class (true adds, false removes).
code »
goog.dom.classlist.enableAll(elementclassesToEnableenabled)
Adds or removes a set of classes depending on the enabled argument. This method may throw a DOM exception for an invalid or empty class name if DOMTokenList is used.
Arguments:
element : !Element
DOM node to add or remove the class on.
classesToEnable : goog.array.ArrayLike.<string>
An array-like object containing a collection of class names to add or remove from the element.
enabled : boolean
Whether to add or remove the classes (true adds, false removes).
code »
goog.dom.classlist.get(element) !goog.array.ArrayLike
Gets an array-like object of class names on an element.
Arguments:
element : Element
DOM node to get the classes of.
Returns: !goog.array.ArrayLike  Class names on element.
code »
goog.dom.classlist.remove(elementclassName)
Removes a class from an element. This method may throw a DOM exception for an invalid or empty class name if DOMTokenList is used.
Arguments:
element : Element
DOM node to remove class from.
className : string
Class name to remove.
code »
goog.dom.classlist.removeAll(elementclassesToRemove)
Removes a set of classes from an element. Prefer this call to repeatedly calling goog.dom.classlist.remove if you want to remove a large set of class names at once.
Arguments:
element : Element
The element from which to remove classes.
classesToRemove : goog.array.ArrayLike.<string>
An array-like object containing a collection of class names to remove from the element. This method may throw a DOM exception if classesToRemove contains invalid or empty class names.
code »
goog.dom.classlist.set(elementclassName)
Sets the entire class name of an element.
Arguments:
element : Element
DOM node to set class of.
className : string
Class name(s) to apply to element.
code »
goog.dom.classlist.swap(elementfromClasstoClass) 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. This method may throw a DOM exception if the class names are empty or invalid.
Arguments:
element : Element
DOM node to swap classes on.
fromClass : string
Class to remove.
toClass : string
Class to add.
Returns: boolean  Whether classes were switched.
code »
goog.dom.classlist.toggle(elementclassName) 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. This method may throw a DOM exception if the class name is empty or invalid.
Arguments:
element : Element
DOM node to toggle class on.
className : string
Class to toggle.
Returns: boolean  True if class was added, false if it was removed (in other words, whether element has the class after this function has been called).
code »

Global Properties

goog.dom.classlist.ALWAYS_USE_DOM_TOKEN_LIST :
Override this define at build-time if you know your target supports it.
Code »

Package dom

Package Reference