Is there a way in jQuery to count how many divs you have and put that number into a string
<div class="name">SOME TEXT</div>
<div class="name">SOME OTHER TEXT</div>
<div class="different">DIFFERENT TEXT</div>
So count the divs with class name
and then put that into a string so the output would be this
var strNoDivs = 2
Any ideas?
Thanks
Jamie
var nb = $('div.name').length;
First option is:
var count= $('div.name').length;
or filter() function can be used too.
var count= $('div').filter('.aaa').length;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With