Getting the index of a current element across all matched elements in the DOM

前端 未结 3 1670
滥情空心
滥情空心 2020-12-18 03:22

I have a DOM structure that looks like this:

3条回答
  •  没有蜡笔的小新
    2020-12-18 03:50

    $('.current').index('section');
    

    See the docs on index.

    If a selector string is passed as an argument, .index() returns an integer indicating the position of the original element relative to the elements matched by the selector. If the element is not found, .index() will return -1.

提交回复
热议问题