更新:2007 年 11 月
提供访问 Sys.UI.DomElement 类的 getElementById 方法的快捷方式。此成员是静态的,可在不创建类实例的情况下调用。
$get(id, element);
参数
项 |
定义 |
|---|---|
id |
要查找的 DOM 元素的 ID。 |
element |
要搜索的父元素。默认值为 document 元素。 |
示例
下面的示例演示如何使用 $get 方法。此代码摘自 DomElement 类概述中一个更大的示例。
// 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);