<!DOCTYPE html>
<html>
<body>
<h1>The HTMLCollection Object</h1>
<h2>The namedItem() Method</h2>
<p id="myElement">The namedItem() method returns the element with the specified id or name.</p>
<p>Click "Get" to get the content of the p element with id="myElement":</p>
<button onclick="myFunction()">Get</button>
<p id="demo"></p>
<script>
function myFunction() {
const collection = document.getElementsByTagName("p");
const element = collection.namedItem("myElement");
document.getElementById("demo").innerHTML = element.innerHTML;
}
</script>
</body>
</html>