jquery selector before-last

后端 未结 2 773
忘了有多久
忘了有多久 2021-01-03 20:22

I have a dynamic list and need to select the before last item.

  • &l
2条回答
  •  感情败类
    2021-01-03 20:51

    You can use .eq() with a negative value (-1 is last) to get n from the end, like this:

    $(".album li").eq(-2).attr("id"); // gets "li-9"
    

    You can test it here.

提交回复
热议问题