Saved X
Google login
SignUp with Email
X

Get count of div by class in javascript

theindreshverma ( Added  Sep 18, 10:35 pm )
Login

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>

Sourcecode Tags

More Sourcecodes

More Sourcecodes