How do I select only the 4th and higher LIs in each UL?
Posted
by KatieK
on Stack Overflow
See other posts from Stack Overflow
or by KatieK
Published on 2010-06-01T00:07:37Z
Indexed on
2010/06/01
0:13 UTC
Read the original article
Hit count: 170
For this XHTML:
<ul class="collapse">
<li>One</li>
<li>Two</li>
<li>Three</li>
<li>Four</li>
<li>Five</li>
</ul>
<ul class="collapse">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
Using jQuery, how do I select only the 4th and higher LIs in each UL?
I've tried:
$("ul.collapse li:gt(2)").css("color", "red");
But it selects the 4th and higher LIs in the whole document. "Four", "Five", and "1", "2", "3", "4" are red.
© Stack Overflow or respective owner