开发者

find position of <li>

开发者 https://www.devze.com 2023-01-19 07:49 出处:网络
I am trying to find the position of Test3 in jquery can someone lead me down the right path please. I need jquery to display 5

I am trying to find the position of Test3 in jquery can someone lead me down the right path please.

I need jquery to display 5

<ul id="numeric" class="sortable boxier" style="margin-right: 1em;">
<li>Test7</li>
<li>Test2</li>
<li>Test6</li>
<li>Test5</li>
<li>Test3</li>
<li>Test8</li>
</ul>

T开发者_开发问答hank you


$('li:contains(Test3)').index()

Note that this uses 0-based indexing, so it will actually display 4. You can add 1 if you want to start your count at 1.

0

精彩评论

暂无评论...
验证码 换一张
取 消