Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selector to select third list item?

Suppose a HTML markup like this:

<ul>
    <li>List item 1</li>
    <li>List item 2</li>
    <li>List item 3</li><!-- I want to select only this -->
</ul>

Would it be possible to select only the third list item in the unordered list element? I've been browsing the jQuery documentation but I can't find any selector that could do this.

like image 330
Richard Knop Avatar asked Dec 03 '22 05:12

Richard Knop


1 Answers

You may want to use the nth-child selector

$('ul li:nth-child(3)')
like image 105
Neil Aitken Avatar answered Dec 17 '22 12:12

Neil Aitken