Is it possible using jQuery to count the number of div elements?
I have this code:
JavaScript
6
1
<div id = "center">
2
<div class ="name">text text</div>
3
<div class ="name">text text text </div>
4
<div class ="name">text </div>
5
</div>
6
And get number: 3
Advertisement
Answer
$("#center div").length
will give you the count.