dojo/dom-class¶
Project owner: | Eugene Lazutkin |
---|---|
since: | V1.7 |
Contents
This module defines the core dojo DOM class API. The standard return variable for this module is domClass
.
Features¶
AMD Features¶
-
Returns whether or not the specified classes are a portion of the class list currently applied to the node.
-
Adds the specified classes to the end of the class list on the passed node. Will not re-apply duplicate classes.
-
Removes the specified classes from node. No
domClass.contains
check is required. -
Replaces one or more classes on a node if not present. Operates more quickly than calling
domClass.remove
anddomClass.add
-
Adds a class to node if not present, or removes if present. Pass a boolean condition if you want to explicitly add or remove. Returns the condition that was specified directly or indirectly.
Legacy features are set in dojo/_base/html.
Examples¶
Here is an example of using domClass.contains
to determine if a DOM node contains a particular class.
require(["dojo/dom-class"], function(domClass){
if (domClass.contains("someNode", "aSillyClassName")){
console.log("someNode contains aSillyClassName");
}else{
console.log("someNode does not contain aSillyClassName");
}
});
See also¶
- dojo/dom - Core DOM API
- dojo/dom-attr - Dojo DOM Attribute API
- dojo/dom-prop - DOM Property API
- dojo/dom-style - DOM Style API
- dojo/_base/html - Legacy API aliases
API Reference: dojo.dom-class