ie in JS getElementsByTagName cannot get element bugs
Definitions and usageThe getElementsByTagName () method returns a collection of objects with the specified label name.
Grammardocument.getElementsByTagName (tagname) descriptionThe order in
Getelementbyid getelementsbyname getelementsbytagname difference and summary
1st Floor
Getelementbyid getelementsbyname getelementsbytagname difference and summaryIn the Web standard, you can use getelementbyid (), getelementsbyname (),
Document directory
Syntax
Description
Example 1
Example 2
Example 3
Definition and usage
The getelementsbytagname () method returns a set of objects with the specified tag name.Syntax
document.getElementsByTagName(tagname)Description
The
function tag (Name,elem) {if (!document.getelementsbytagname) return false;Return (Elem | | document). getElementsByTagName (name);}
document.getelementsbyclassname = function (Classname,obox) {
Applies to getting all HTML elements
getElementById () and getElementsByTagName () one is the ID and the other is name what is the difference between them, getElementById () only for HTML operations and not the XML file processing, But getElementsByTagName is OK. Let's take a look at
Getelementbyid () getelementsbyname () getelementsbytagname ()
DifferenceIn the Web standard, you can use getelementbyid (), getelementsbyname (), and getelementsbytagname () to access any tag in javasnent:
1 getelementbyid ("ID ")Getelementbyid ()
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
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
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
Reference: http://www.w3school.com.cn/jsref/met_doc_getelementsbytagname.aspHTML DOM Document ObjectDefinition and usageThe getElementsByTagName () method returns a collection of objects with the specified label
Get elements by tag name--getElementsByTagNameStandard
DOM 1 is defined in and two interface, and the prototypes indicate the order in which they are Element Document encountered in NodeList getElementsByTagName(in DOMString tagname) the first
Getelementbyid getelementsbyname getelementsbytagnameKnowledge needs to be updated and new, and those you have read will also be forgotten. You need to consolidate it. ^_^In the Web standard, you can use getelementbyid (), getelementsbyname (), and
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,
getElementsByTagName (): The purpose of the method is to look for all elements that have a given signature.element = document.getElementsByTagName (tagName);This method returns a collection of nodes that can be treated as an array. The length
The getelementsbytagname of JS and $ (élement) of JQ both get the elements in Dom, but they also have some differences and paste the Code:VaR El = Document. getelementsbytagname ('P ');VaR P = ' ';$ ('Body'). append (P );Console. Log (El. Length) //
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,
Document. getelementsbyname () obtains the control object based on the control name. Because the control name can be the same, an array of objects is returned.
Document. getelementbyid () is used to obtain the control object based on the control ID.
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
So I tested it:
Copy codeThe Code is as follows: var stringToDom = function (text ){
Var doc;
If (window. ActiveXObject ){
Doc = new ActiveXObject ("MSXML2.DOMDocument ");
Doc.loadXML(text).doc umentElement;
} Else {
Doc = (new DOMParser ().
1, getElementByIdreturns the first in the same ID object, in the order in which the page appears , or null if there are no eligible objectsExampledocument.getElementById ("Id1"). Value;2, GetelementsbynameFunction: Finds an array of elements of the
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.