JavaScript Document own method: getElementsByName()
[this page | pdf | back links]
The getElementsByName() method (when
applied to the document object of the JavaScript
DOM) returns a
NodeList containing all the elements with the specified name attribute.
 
It
has the following syntax with the following parameters. It returns a
NodeList representing a collection of all relevant elements, ordered as they
appear in the source code.
 
document.getElementsByName(name)
 
 
  | Parameter | Required / Optional | Description | 
 
  | name | Required | String specifying the name
  attribute value of the elements you want to obtain | 
 
EXAMPLE:
HTML USED IN THIS EXAMPLE:
| <!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>
table,td,tr,th,caption {border: thin solid black; border-collapse: collapse;}
</style>
</head>
<body>
<table>
  <tr><th>Dom method</th><th>Value returned</th></tr>
  <tr><td>getElementsByName</td><td id="x3"></td></tr>
</table>
<br>
<input name="xname" value="entry"><br>
<script>
document.getElementById("x3").innerHTML = 
    document.getElementsByName("xname")[0].tagName;
</script>
</body>
</html>
 | 
FUNCTION THAT MAY ASSIST IN TESTING WHETHER FEATURE IS SUPPORTED:
| function isSupportedJavaScriptMethodDomGetElementsByName() {
  return !!document.getElementsByName;
} | 
NAVIGATION LINKS
Contents | Prev | Next | JavaScript DOM (and BOM)