Discover html getelementsbytagname, include the articles, news, trends, analysis and practical advice about html getelementsbytagname on alibabacloud.com
Getelementbyid getelementsbyname getelementsbytagname difference and summary
1st Floor
Getelementbyid getelementsbyname getelementsbytagname difference and summaryIn the Web standard, you can use getelementbyid (), getelementsbyname (),
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
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
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
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
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
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
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.
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.