views:

34

answers:

2

Hello

I want hide every LI from a UL other than the first, but the result is that it hides all except the very first LI of all UL's. (I want "show" the first LI of every UL).

How can i do that???

 <ul>
    <li>first</li>
    <li>second</li>
 </ul>

 <ul>
    <li>first</li>
    <li>second</li>
 </ul>

When i do this only identified the first item of all UL

    $('.smallYears ul li:not(:first)').hide();          

Thank you very much

+2  A: 

If you want to exclude the first UL, then you need to put the :not() on that.

$('.smallYears ul:not(:first) li').hide();   

Or did you mean that you want to exclude the first LI of each UL. If so, do this:

$('.smallYears ul li:not(:first-child)').hide();

Or:

$('.smallYears ul li:nth-child(1)~li').hide();
patrick dw
+1  A: 

Completely untested, but something like the following might work.

$('.smallYears ul li:not(:first-child )').hide();    

You're running into dramas as :first is basically an alias for :eq(0), which is the first item in the jQuery collection.

Dan F