Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Count the number of <div>

Is it possible using jQuery to count the number of div elements?

I have this code:

<div id = "center">
  <div class ="name">text text</div>
  <div class ="name">text text text ... </div>
  <div class ="name">text ...</div>
</div>

And get number: 3

like image 458
user319854 Avatar asked Aug 19 '10 13:08

user319854


1 Answers

$("#center div").length will give you the count.

like image 110
Philippe Leybaert Avatar answered Oct 17 '22 20:10

Philippe Leybaert