yrksundeep yrksundeep - 1 year ago 90
Javascript Question

How to find the count of elements using jQuery

I have a span tag and that holds some n number of span tags.. can I get the number of span tags available with in the parent span using Jquery.


<span class="x">
<span id="1">one</span>
<span id="2">two</span>
<span id="3">three</span>

now i should find the count of number of span tags inside the parent span and my output is 3 according to the above scenario.

please help me..

Answer Source

my version :)

$('span.x > span').length
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download