Javascript get find Method

Source: Internet
Author: User
$ Get Shortcut Method

Provides a shortcut cut toGetelementbyidMethod ofSYS. UI. domelementClass. 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 inDomelementClass 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. }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.