Html 按 tab 时跳过输入
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13435217/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Skip input when press tab
提问by eshellborn
I have a form where there are three input boxes with three drop down select tags beside them. I want to be able to press the tab key and go from one input to another, but you have to press it twice because it goes to the drop down menu after the input box. Is there a way I can make it "skip over" the drop down menu and go right to the next input box when you press tab?
我有一个表单,其中有三个输入框,旁边有三个下拉选择标签。我希望能够按下 Tab 键并从一个输入转到另一个输入,但是您必须按两次它,因为它会在输入框之后进入下拉菜单。有什么方法可以让它“跳过”下拉菜单并在按下 Tab 键时直接转到下一个输入框?
采纳答案by zzzzBov
You can specify the tabbing order explicitly by setting the [tabindex]
attribute:
您可以通过设置[tabindex]
属性来显式指定跳转顺序:
[tabindex]
:没有[tabindex]
:<input type="text" /> <!-- first -->
<input type="checkbox" /> <!-- second -->
<select>...</select> <!-- third -->
with [tabindex]
:与[tabindex]
:<input type="text" tabindex="1" /> <!-- first -->
<input type="checkbox" tabindex="3" /> <!-- third -->
<select tabindex="2">...</select> <!-- second -->
回答by el Dude
tabindex=0
property makes inputs skippable in case when other inputs have tabindex values above zero.
tabindex=0
属性使输入可跳过,以防其他输入的 tabindex 值高于零。
tabindex="-1"
makes input
completely skippable
tabindex="-1"
使input
完全可跳过