Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<body>
<h1>The Document Object</h1>
<h2>The getElementsByClassName() Method</h2>
<div class="example">
A div element with class="example"
</div>
<div class="example">
A div element with class="example"
</div>
<p class="example">
A p element with class="example"
</p>
<p>The number of elements with class="example" is:</p>
<p id="demo"></p>
<script>
let numb = document.getElementsByClassName("example").length;
document.getElementById("demo").innerHTML = numb;
</script>
</body>
</html>