Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<style>
div {
  border: 1px solid black;
  padding:16px;
}
</style>
<body>
<h1>The Element Object</h1>
<h2>The getElementsByClassName() Method</h2>
<div id="myDIV">
  <p class="child">I am a paragraph.</p>
  <p class="child">I am a paragraph.</p>
  <p class="child">I am a paragraph.</p>
</div>
<p>The number of elements with class "child" are:</p>
<p id="demo"></p>
<script>
const element = document.getElementById("myDIV"); 
const nodes = element.getElementsByClassName("child");
document.getElementById("demo").innerHTML = nodes.length;
</script>
</body>
</html>