Get count of div by class in javascript

Count total elements by using class in javascript

<div class="counter"></div>
<div class="counter"></div>
<div class="counter"></div>
<div class="counter"></div>
<div class="counter"></div>

<script>
var len = document.querySelectorAll('.counter').length;
document.write(len);
</script>

Related Sourcecode

More Sourcecode

×
Google login
SignUp with Email
X