Definition and Usage
The getElementsByName() method accesses all elements with the specified name.
Syntax
document.getElementsByName(
name)
Parameter | Description |
---|---|
name | Required. The name of the element you want to access/manipulate |
The getElementsByName() method is supported in all major browsers.
Example
Example
Alert the number of elements with a specific name:
<script type="text/javascript">
var x=document.getElementsByName("x");
alert(x.length);
</script>
var x=document.getElementsByName("x");
alert(x.length);
</script>
Try it yourself »