Compartilhar via


Sys.UI.DomElement addCssClass Method

Adds a CSS class to a DOM element if the class is not already part of the DOM element. This member is static and can be invoked without creating an instance of the class.

Sys.UI.DomElement.addCssClass(element, className);

Parameters

Term

Definition

element

The Sys.UI.DomElement object to add the CSS class to.

className

The name of the CSS class to add.

Remarks

If the element does not support a CSS class, no change is made to the element.

Example

The following example shows how to use the addCssClass method. This code is part of a larger example found in the DomElement class overview.

// Add CSS class
Sys.UI.DomElement.addCssClass($get("Button1"), "redBackgroundColor");
// Add CSS class
Sys.UI.DomElement.addCssClass($get("Button1"), "redBackgroundColor");

See Also

Reference

Sys.UI.DomElement Class

Other Resources

Language Reference