Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

find element based on tabindex

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.

like image 473
amateur Avatar asked Jul 29 '11 11:07

amateur


People also ask

What does Tabindex =- 1 mean?

A negative value (usually tabindex="-1" ) means that the element is not reachable via sequential keyboard navigation, but could be focused with JavaScript or visually by clicking with the mouse. It's mostly useful to create accessible widgets with JavaScript.

What is the difference between Tabindex 0 and Tabindex =- 1?

tabindex="1" (or any number greater than 1) defines an explicit tab or keyboard navigation order. This must always be avoided. tabindex="0" allows elements besides links and form elements to receive keyboard focus.

Is Tabindex inherited?

Passed tabIndex is not inherited and added to element of Checkbox.


3 Answers

With the attribute selector:

$("[tabindex=7]") // all elements with tabindex=7
like image 111
pimvdb Avatar answered Oct 21 '22 03:10

pimvdb


You can get it with the following jQuery

$('input[tabindex=7]')
like image 33
Nalum Avatar answered Oct 21 '22 05:10

Nalum


You can find the element by an attribute selector:

$('[tabindex=7]')
like image 8
Jakub Roztocil Avatar answered Oct 21 '22 04:10

Jakub Roztocil