Getelementbyid getelementsbyname getelementsbytagname difference and summary
1st Floor
Getelementbyid getelementsbyname getelementsbytagname difference and summaryIn the Web standard, you can use getelementbyid (), getelementsbyname (),
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
Getelementsbyname ("test") is to extract all the elements whose name attribute is test and put them in a set and return them to you.Getelementsbytagname ('input') is to extract all the text boxes, single choice, check, and buttons and put them in a
For the most classic explanation of ID & Name, "ID is like our ID card, and Name is like our Name". That is to say, ID is unique in an html document, but the Name can be repeated, just as our personal names can be repeated, but the ID card is indeed
Get multivariate by the name attribute--getElementsByNameStandard
DOM 1 is defined in HTMLDocument Interface, and NodeList getElementsByName(in DOMString elementName) the method does not throw any exceptions.
DOM 2 is still defined in,
Problem:When writing a dynamic HTML table today, we need to use statistics on the data in td. During the generation, we set the name attribute of td, but document. getElementsByName ("_ test") can obtain this object and print and display the [object]
In the past, document. getelementbyid was often used to obtain the ID tag attribute in HTML.
Document. getelementbyname (note that there is no s) to obtain the name tag attribute. the browser reports an error. I checked the information and found
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.
Tag: getelementbyid
Getelementsbyname
Getelementsbytagname
Getelementbyid:
Syntax: Document. getelementbyidx (ID)Parameter: ID: Required string)Returned value: object;Returns the first object with the same ID. If no matching object exists,
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.