In the Web standard, you can use getelementbyid (), getelementsbyname (), and getelementsbytagname () to access any tag in the document.
(1) getelementbyid ():
Getelementbyid () can access a specific element in the document. As the name suggests,
In the Web standard, you can use getelementbyid (), getelementsbyname (), and getelementsbytagname () to access any tag in the document.
(1) getelementbyid ():
Getelementbyid () can access a specific element in the document. As the name suggests,
Web standards can access any of the tags in the document through getElementById (), Getelementsbyname (), and getElementsByTagName ().(1) getElementById ():getElementById () can access a specific element in the document, as the name implies, by
However, if you need to find a specific element in the document, the most effective method is getelementbyid ().
However, when using getelementbyid, The results may be different for different browsers.
CopyCode The Code is as follows: text1:
Text2
Click the button to disable the button and display the text [processing...]. The getelementbyid button tag value is text, and the getelementbyid value is
[Reprinted with the source: lanmanck.net. csdn. blog]
If jquery is used on the Internet,
In js writing, you often need to obtain the id object. If you use getElementById directly to obtain the object, there are many codes and the old browser does not support this attribute. You can consider using the following code. For example, use _ $
Any one of the labels in document:
1, getElementById ()
getElementById () can access a specific element in the document, as the name implies, by using an ID to get the element, so you can only access the element that has the ID set.
For example,
Get elements by ID--getElementByIdStandard
DOM 1, defined in Interface, is a HTMLDocument prototype Element getElementById(in DOMString elementId) that returns NULL when no element with the corresponding ID exists, and the method does not
Document. getElementById ('text1'). *** statement parsing !!! Do I need the source code? JScriptcodevarxmlhttp; functionhello () {xmlhttp = ajax1 (); document. getElementById ('text1'). *** statement parsing !!!
Do I need the source code?
Getelementbyid getelementsbyname getelementsbytagname difference and summary
1st Floor
Getelementbyid getelementsbyname getelementsbytagname difference and summaryIn the Web standard, you can use getelementbyid (), getelementsbyname (),
Use your brain as a browser to execute the following code twice: IE6 and IE9:
Copy codeThe Code is as follows: function testFunc (){
Alert ('test ')
}
$ (Function (){
Var g = document. getElementById,
W = window. testFunc;
// G
Alert (typeof (g
However, if you need to find a specific element in the document, the most effective method is getElementById ().However, when using getElementById, The results may be different for different browsers.Copy codeThe Code is as follows:Text1:Text2:I
Assume that the textbox1 character is copied to textbox2 in real time. The Code is as follows:
The above code can work well. However, I think the document on the equal sign side 2. getelementbyid ("... ") the code is too long. You want to assign
From lcx's blog
In the WEB standard, you can use getElementById (), getElementsByName (), and getElementsByTagName () to access any tag in the DOCUMENT:
1. getElementById ()GetElementById () can access a specific element in the DOCUMENT. As the name
Can getElementById be used in any browser? Q: I know that getElementById can be used in IE, but I don't know if it can be used in other browsing scenarios, such as Firebox, Opera, netscape
Answer:
GetElementById is a standard method
Getelementbyid () getelementsbyname () getelementsbytagname ()
DifferenceIn the Web standard, you can use getelementbyid (), getelementsbyname (), and getelementsbytagname () to access any tag in javasnent:
1 getelementbyid ("ID ")Getelementbyid ()
Document. form name. object Name. attribute values may not be supported by third parties in this way. We recommend that you use the getelementbyid (), getelementsbyname (), and getelementsbytagname () methods () the result is an array.On the
Web
Standard
Getelementbyid (), getelementsbyname (), and getelementsbytagname ()
Access
Billing NENT
Any tag in:
1 getelementbyid ("ID ")
Getelementbyid ()
Accessible
Billing NENT
A specific element in
ID
So you can only
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.