How to get a specific jQuery item from a list of items?

后端 未结 5 1190
难免孤独
难免孤独 2021-01-07 23:23

I have this:

  • first
  • second
  • third
  • fourth
5条回答
  •  一向
    一向 (楼主)
    2021-01-08 00:06

    The get method returns the DOM element, so then you would have to wrap it inside a new jQuery object.

    You can use the eq method:

    var j = $('ul li').eq(1); // gets the second list item
    

提交回复
热议问题