javascript get find 方法

$get Shortcut Method

Provides a shortcut to the getElementById method of the Sys.UI.DomElement class. This member is static and can be invoked without creating an instance of the class.

Syntax

  1. $get(id, element);

 

Term

 

 

 

 

Definition

id

The ID of the DOM element to find.

element

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

Example

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

cs
  
  
  1. // Add handler using the getElementById method
  2. $addHandler(Sys.UI.DomElement.getElementById("Button1"), "click", toggleCssClassMethod);
  3. // Add handler using the shortcut to the getElementById method
  4. $addHandler($get("Button2"), "click", removeCssClassMethod);
vb
  
  
  1. // Add handler using the getElementById method
  2. $addHandler(Sys.UI.DomElement.getElementById("Button1"), "click", toggleCssClassMethod);
  3. // Add handler using the shortcut to the getElementById method
  4. $addHandler($get("Button2"), "click", removeCssClassMethod);
--------------------------------------

$find Shortcut Method

Provides a shortcut to the findComponent method of the Sys.Application class. This member is static and can be invoked without creating an instance of the class.

Syntax

 

  1. var o = $find(id, parent);
Arguments

id :

A string that contains the ID of the component to find.

parent :

(Optional) The component or element that contains the component to find.

Return Value

A Component object that contains the component with the specified ID, if found; otherwise, null.

Remarks

For details about the method that this shortcut represents, see findComponent Method.

Example

The following example uses the $find method to check whether a custom component exists and to notify the user if the component is missing.

CS
    
    
  1. function checkComponent() {
  2.     if (!($find('MyComponent', div1))) {
  3.         div1.innerHTML = 'MyComponent is not available.';
  4.     }
  5. }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值