开发者

Hide all LI from a separate UL other than the first

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


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();
  • http://api.jquery.com/first-selector/
  • http://api.jquery.com/first-child-selector/


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜