find element based on tabindex

2019-04-19 23:19发布

Using jquery or javascript, how can I find the input element in the DOM that has a particular tabindex set to it, eg.

<input id="txtInput" type="text" maxlength="5" tabindex="7">

I would want this element returned if I was searching for the element with tabindex = 7.

3条回答
姐就是有狂的资本
2楼-- · 2019-04-19 23:53

You can get it with the following jQuery

$('input[tabindex=7]')
查看更多
祖国的老花朵
3楼-- · 2019-04-19 23:56

You can find the element by an attribute selector:

$('[tabindex=7]')
查看更多
放我归山
4楼-- · 2019-04-20 00:12

With the attribute selector:

$("[tabindex=7]") // all elements with tabindex=7
查看更多
登录 后发表回答