Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<body>
<h1>The HTMLCollection Object</h1>
<h2>The item() Method</h2>
<p>[0] is a shorthand for the item(0).</p>
<p>Click "Change" to change the content of the first paragraph.</p>
<button onclick="myFunction()">Change</button>
<script>
function myFunction() {
  const collection = document.getElementsByTagName("p")[0];
  collection.innerHTML = "Changed!";
}
</script>
</body>
</html>