<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>Check the checkboxes that have a name="animal":</p>
<script>
const collection = document.getElementsByName("animal");
for (let i = 0; i < collection.length; i++) {
if (collection[i].type == "checkbox") {
collection[i].checked = true;
}
}
</script>
</body>
</html>