Sys.UI.DomElement setVisible Method
Sets a DOM element to be visible or hidden. This member is static and can be invoked without creating an instance of the class.
Sys.UI.DomElement.setVisible(element, value);
Parameters
Term |
Definition |
---|---|
element |
The target DOM element. |
value |
true to make element visible on the Web page; false to hide element. |
Remarks
Use the setVisible method to set a DOM element as visible or hidden on the Web page. If you invoke this method with value set to false for an element whose visibility mode is set to "hide," the element will not be visible. However, it will occupy space on the page. If the element's visibility mode is set to "collapse," the element will occupy no space in the page.
For more information about how to set the layout characteristics of hidden DOM elements, see Sys.UI.DomElement setVisibilityMode Method.
Example
The following example shows how to use the setVisible method. The code toggles the visibility of an element.
var anElement = $get("Label1");
if (Sys.UI.DomElement.getVisible(anElement)){
Sys.UI.DomElement.setVisible(anElement, false);
}
else{
Sys.UI.DomElement.setVisible(anElement, true);
}