Previous topic

dojo._base.xhr

Next topic

dojo.addOnLoad

This Page

dojo.addClassΒΆ

Adds a CSS class to a node.

1
dojo.addClass("someNode", "someClass");

The node can be a string ID of a DOM Node, or a reference to a DOM Node:

1
2
var node = dojo.byId("someNode").parentNode;
dojo.addClass(node, "someNodesParent");

When using addClass with dojo.query, the node parameter is omitted:

1
dojo.query(".randomClass").addClass("anotherClass");

will find all the nodes with class="randomClass" and add "anotherClass" to the class attribute.

Relates to dojo.hasClass and dojo.removeClass