jQuery Children length of an ol

Posted by DMin on Stack Overflow See other posts from Stack Overflow or by DMin
Published on 2010-05-31T02:09:26Z Indexed on 2010/05/31 2:12 UTC
Read the original article Hit count: 293

Filed under:
|
|

I am trying to count the child elements of an OL

jQuery :

$(document).ready(function(){

$("#my_select").change(function(){
    alert($("#ol3").children.length);
                                     });});

HTML:

<ol id="ol1">
    <li class="2">Location 1-1</li>
</ol>

<ol id="ol2">
    <li class="15">Location 2-1</li>
    <li class="20">Location 2-2</li>
</ol>

<ol id="ol3">
    <li class="17">Location 3-1</li>
    <li class="16">Location 3-2</li>
    <li class="14">Location 3-3</li>
</ol>

I always get the number 2 no matter how many li are there under the ol.

Know what's going on..?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about html