Set tabindex for button not working

I have few controls on the form. I have to set tabIndex in an order that is not natural for their order of creation in HTML. There is a button at the end of the fag, and tabIndex does not get set (it never focuses) only on this element.

<button id="btnSave" tabindex = "86" title='click here'>Submit Here</button> 

What could be the reason?

Appreciate your help.

+4
source share
3 answers

If you install tabindex only in the button element, this element will be the first in the navigation, which means that you will not get it directly from the last input field (but only through some browser-dependent elements in the browser your own user interface, such as the search field and address field). See the HTML 4.01 specification on tabindex .

If you installed tabindex in other fields, send a demo showing the behavior - in a simple test in several browsers, tabindex works fine when configured in all fields.

+3
source

Tabindex Practices

I usually suggest not installing Tabindex with any additional values, because for any fields / components on your web page, if we follow this rule, we need to maintain the same incremental tabindex values ​​for upcoming fields, and we basically show / hide fields / components based on certain conditions so that the time of the tab indices does not work sequentially.

I highly recommend that it is best to use Tabindex greater than 0 and use only Tabindex -1 and 0 wherever required

TabIndex = "- 1"

Setting tabindex = "- 1" allows you to set the focus of elements using a script, but not put it in the order of the page tabs. This is convenient when you need to move the focus to what you updated using a script or outside the user's actions.

TabIndex = "0"

Setting tabindex = "0" will lead to the element and make it focusable. It does not set the position of the elements in tab order, it simply allows the user to focus the element in the order determined by its location using the DOM.

tabindex = "1" (or any value> 0)

Do not set tabindex = "1" or any value greater than zero (or any positive value).

0
source

try:

  <input type="button" value="Sumit here" tabindex="90" /> 

check that your index will be considered equal to zero under it parrent! index 90 is too much for html.

-one
source

Source: https://habr.com/ru/post/1392027/


All Articles