How to change input field switch sequence (swithcing input field using Tab key) on a web page?

↘锁芯ラ 提交于 2019-12-08 12:55:55

问题


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:


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



来源:https://stackoverflow.com/questions/7455865/how-to-change-input-field-switch-sequence-swithcing-input-field-using-tab-key

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!