goog.dom.classlist
Functions
add( element, className ) → void
void
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.
Parameters |
|
---|
addAll( element, classesToAdd ) → void
void
Convenience method to add a number of class names at once.
Parameters |
|
---|
addRemove( element, classToRemove, classToAdd ) → void
void
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.
Parameters |
|
---|
contains( element, className ) → boolean
boolean
enable( element, className, enabled ) → void
void
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.
Parameters |
|
---|
enableAll( element, classesToEnable, enabled ) → void
void
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.
Parameters |
|
---|
get( element ) → IArrayLike<?>
IArrayLike<?>
Gets an array-like object of class names on an element.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
remove( element, className ) → void
void
Removes a class from an element. This method may throw a DOM exception for an invalid or empty class name if DOMTokenList is used.
Parameters |
|
---|
removeAll( element, classesToRemove ) → void
void
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.
Parameters |
|
---|
set( element, className ) → void
void
Sets the entire class name of an element.
Parameters |
|
---|
swap( element, fromClass, toClass ) → boolean
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.
Parameters |
| ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns |
|
toggle( element, className ) → boolean
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.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
Compiler Constants
goog.dom.classlist.ALWAYS_USE_DOM_TOKEN_LIST → boolean
boolean
Override this define at build-time if you know your target supports it.