Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<body>
<h1>The Document Object</h1>
<h2>The document.getElementsByName Method</h2>
Cats:
<input name="animal" type="checkbox" value="Cats">
Dogs:
<input name="animal" type="checkbox" value="Dogs">
<p>Number of elements with name="animal" is:</p>
<p id="demo"></p>
<script>
let num = document.getElementsByName("animal").length;
document.getElementById("demo").innerHTML = num;
</script>
</body>
</html>