How to change input field switch sequence (swithci

2019-06-13 03:31发布

On a web page, if there are input fields, pressing Tab key switches them, but in a particular order, is there a way to change this order and set it to some different order?

If this can be done in html, it is preferable, but if some other scripting language (javascript etc) can do it, it is also acceptable.

1条回答
2楼-- · 2019-06-13 04:14

The attribute tabindex takes care of that http://www.w3.org/TR/WCAG-TECHS/H4.html to exclude a element completely from the tabindex give it a index of -1 the lowest safe index to start with is 1.

0 is the default value so should be avoided when explicitly setting the tabindex

<input tabindex=1 type="text" name="my_input1">
<input tabindex=3 type="text" name="my_input2">
<input tabindex=2 type="text" name="my_input3">

The tab would go from the my_input1 to my_input3 to my_input2 field in this example

tabindex may be used on a, area, button, input, object, select and textarea

查看更多
登录 后发表回答