12

Possible Duplicate:
get the elements number inside parent div jquery

Is it possible to get the number of elements that are inside a div?

<div id=count">
   <span></span>
   <span></span>
   <span></span>
   <span></span>
</div>

the resut should be

 4
Community
  • 1
  • 1
coiso
  • 7,151
  • 12
  • 44
  • 63

2 Answers2

37
$('#count').children().length; // 4
David G
  • 94,763
  • 41
  • 167
  • 253
2
var count = $('#count > *').length;
dfsq
  • 191,768
  • 25
  • 236
  • 258