HTML DOM getElementsByName()Method
Document Object
Definition and Usage
The getElementsByName() method returns a collection of objects with the specified name.
Syntax
document.getElementsByName(name)
| Parameter | Description |
|---|---|
| name | Required. The name of the element. |
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the getElementsByName() method
Example
Example
Alert the number of elements with the specified name:
<script>
var x=document.getElementsByName("x");
alert(x.length);
</script>
var x=document.getElementsByName("x");
alert(x.length);
</script>
Try it yourself »
Document Object Other Extensions