Document. getelementbyid

Source: Internet
Author: User

Document. getelementbyid ("") is an object, which is displayed with alert as "object" rather than a specific value. It has attributes such as value and length, plus. the value is the specific value!

References:

1. Usage of document. getelementbyid and DHTML. CHM

Find the usage of document. getelementbyid on the network today, as follows:

A: Syntax:

Oelement = Document. getelementbyid (SID)

Parameters:

Sid: required. String ).

Return Value:

Oelement: Object (element ).

Note:

Obtains an object based on the specified ID attribute value. Returns the reference of the first object whose ID property value is equal to Sid. If the corresponding object is a group of objects, the first object in the group is returned.

If no matching object exists, null is returned.

 

B: An example is as follows:

 

**************************************** ************************************

**

* The most important part of this function is document. getelementbyid. What is it? *

**

* For document. getelementbyid, this is the case :*

**

* For example, document. getelementbyid ('hdrpageheader _ lbltitle ')*

**

* Indicates that the object whose ID is hdrpageheader_lbltitle is obtained *

**

* <A> AA </a> *

* <A> BB </a> *

* <A> CC </a> *

* <Script language = "JavaScript"> *

* <! --*

* Var idtext = Document. getelementbyid ('hdrpageheader _ lbltitle ')*

* Alert (idtext. innertext )*

* // --> *

* </SCRIPT> *

 

 

C: You can also get the following details:

① Document. getelementbyid sometimes misses the name, which is said to be a bug in IE;

The page contains

<Input type = "hidden" value = "2"/>

<SELECT>

One is the other is

Use document. getelementbyid to obtain the second one. However, the first one is obtained.>

In IE, getelementbyid does not capture the ID first, but first finds the object with the same name...

Two forms. Each form has two textbox. the textbox in the two forms has the same name, but the IDs are different...

So there is no problem in Firefox.

2. Document Object

Http://www.phpx.com/man/dhtmlcn/objects/obj_document.html

Attribute: title; bgcolor; Url; (Use: Document. Title)

Method:
Focus

So that the element gets the focus and executesCode.

Getelementbyid

Obtains the reference of the first object whose ID label attribute is the specified value.

Getelementsbyname

Obtains the object set based on the value of the name tag attribute.

Getelementsbytagname

Obtains an object set based on the specified element name.

Method:
Focus

So that the element gets the focus and executes the code specified by the onfocus event.

Getelementbyid

Obtains the reference of the first object whose ID label attribute is the specified value.

Getelementsbyname

Obtains the object set based on the value of the name tag attribute.

Getelementsbytagname

Obtains an object set based on the specified element name.

Trackback: http://tb.blog.csdn.net/TrackBack.aspx? Postid = 1897389

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.