javascript get find 方法

來源:互聯網
上載者:User
$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. }
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.