Project owner:Eugene Lazutkin

This module defines the core dojo DOM class API. The standard return variable for this module is domClass.


AMD Features

  • domClass.contains

    Returns whether or not the specified classes are a portion of the class list currently applied to the node.

  • domClass.add

    Adds the specified classes to the end of the class list on the passed node. Will not re-apply duplicate classes.

  • domClass.remove

    Removes the specified classes from node. No domClass.contains check is required.

  • domClass.replace

    Replaces one or more classes on a node if not present. Operates more quickly than calling domClass.remove and domClass.add

  • domClass.toggle

    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.


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");
    console.log("someNode does not contain aSillyClassName");

See also

API Reference: dojo.dom-class

Error in the documentation? Can’t find what you are looking for? Let us know!