How can I find the last “li” in a “ul” using jQuery?

后端 未结 5 2062
南方客
南方客 2021-01-04 18:15

I want to check the li that is the last li in ul. How can I check that using jQuery?

5条回答
  •  没有蜡笔的小新
    2021-01-04 19:17

    $('ul#ulscroller').children('li').last();
    

    http://api.jquery.com/last/

    You could also do it like so:

    $('ul#ulscroller').children('li:last-child');
    

    http://api.jquery.com/last-selector/

    Here's an example to illustrate it: http://jsfiddle.net/TheNix/W92vF/

提交回复
热议问题