HTML DOM getElementsByName() Method (original) (raw)

Last Updated : 13 Jun, 2023

The getElementsByName() method returns collection of all elements of particular document by name. This collection is called node list and each element of the node list can be visited with the help of the index.

Syntax:

document.getElementsByName(name)

**Parameter:**This function accepts name of document.

**Return Type:**This function returns collection of elements. By using the build in method length we can find the total number of elements presents inside that particular element. Below example illustrates it clearly.

**Note:**There is no getElementByName() method exists, it is getElementsByName(), with a ā€˜s’.

Example-1:

html `

DOM getElementsByName()