设置tabindex按钮不起作用

Pre*_*shu 6 html button tabindex

我对表单上的控件很少.我必须按照在HTML上创建顺序不自然的顺序设置tabIndex.在fag端有一个按钮,tabIndex没有被设置(它从不聚焦)只在这个元素上.

<button id="btnSave" tabindex = "86" title='click here'>Submit Here</button>
Run Code Online (Sandbox Code Playgroud)

可能是什么原因?

感谢您的帮助.

Gan*_*mar 5

Tabindex最佳做法

Commonly, I would suggest that do not set Tabindex with any incremental values because for any fields/components in your web page if we follow this rule then we need to maintain the same tabindex incremental values for upcoming fields too and also we mostly show/hide the fields/components based on some conditions so that time the tab index will not work consistently.

I strongly suggest the best practice is that we should not use Tabindex Greater than 0 and use only Tabindex -1 and 0 wherever required

tabindex="-1"

Setting tabindex="-1" allows you to set an element’s focus with the script, but does not put it in the tab order of the page. This is handy when you need to move focus to something you have updated via script or outside of user action.

tabindex="0"

Setting tabindex="0" will take an element and make it focusable. It doesn’t set the element’s position in the tab order, it just allows a user to focus the element in the order determined by its location with the DOM.

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

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


S.A*_*hid -2

尝试 :

 <input type="button" value="Sumit here" tabindex="90" />
Run Code Online (Sandbox Code Playgroud)

检查一下,您的索引将从零开始计算在其父项下!索引 90 对于 html 来说太大了。