How to get HTML elements by name attribute in Javascript
Get elements by name
getElementsByName(nameOfNameAttribute)
gets
the elements by name and returns HTMLElement[]
.
Example
<!DOCTYPE HTML>
<html>
<body>
<p name="apple"> apple</p>
<script>
var nameElems = document.getElementsByName("apple");
document.writeln(nameElems.length);
</script>
</body>
</html><!--from ww w . jav a 2 s . c o m-->