Share via


Sys.UI.DomElement getElementById Method

Gets a DOM element that has the specified id attribute. This member is static and can be invoked without creating an instance of the class.

Sys.UI.DomElement.getElementById(id, element);

Parameters

Term

Definition

id

The ID of the element to find.

element

The parent element to search in. The default is the document element.

Return Value

The Sys.UI.DomElement object with the specified ID.

Remarks

The $get method provides a shortcut to the getElementById method of the Sys.UI.DomElement class.

Example

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

// Add handler using the getElementById method
$addHandler(Sys.UI.DomElement.getElementById("Button1"), "click", toggleCssClassMethod);
// Add handler using the shortcut to the getElementById method
$addHandler($get("Button2"), "click", removeCssClassMethod);
// Add handler using the getElementById method
$addHandler(Sys.UI.DomElement.getElementById("Button1"), "click", toggleCssClassMethod);
// Add handler using the shortcut to the getElementById method
$addHandler($get("Button2"), "click", removeCssClassMethod);

See Also

Reference

Sys.UI.DomElement Class

Sys.UI.DomElement $get Method

Other Resources

Language Reference