次の方法で共有


Sys.UI.DomElement toggleCssClass Method

Toggles a CSS class in a DOM element. This member is static and can be invoked without creating an instance of the class.

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

Parameters

Term

Definition

element

The Sys.UI.DomElement object to toggle.

className

The name of the CSS class to toggle.

Remarks

Use the toggleCssClass method to hide a CSS class of an element if it is shown, or to show a CSS class of an element if it is hidden.

Example

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

// Toggle CSS class
Sys.UI.DomElement.toggleCssClass(eventElement.target, "redBackgroundColor");
// Toggle CSS class
Sys.UI.DomElement.toggleCssClass(eventElement.target, "redBackgroundColor");

See Also

Reference

Sys.UI.DomElement Class

Other Resources

Language Reference