English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
getElementsByName()A group of element node objects can be obtained by using the name attribute, and this method is supported by all browsers.
The elements in the returned list are sorted in the order they appear in the source code.
elements in the returned list can be accessed by index number. The index starts from 0.
used for arrayslengthThe attribute determines the number of elements with the specified name, and then all elements can be traversed to extract the required information.
document.getElementsByName(name)
var x = document.getElementsByName("demo");Test See‹/›
All browsers fully support the getElementsByName() method:
Method | |||||
getElementsByName() | Yes | Yes | Yes | Yes | Yes |
Parameter | Description |
---|---|
name | The value of the element's name attribute |
Return Value: | Returns an array-like object containing all child elements with the given name. |
---|---|
DOM Version: | DOM Levels1 |
DOM Document querySelector()Methods
DOM Document querySelectorAll()Methods
DOM Document getElementById()Methods
DOM Document getElementsByTagName()Methods