从 Tab 键顺序中显式排除 html 元素

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3895710/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 04:48:04  来源:igfitidea点击:

Explicitly exclude an html element from the tab order

htmlformstabindex

提问by Jason

Is there anyway to exclude an element from the tab order of a HTML form.

无论如何要从 HTML 表单的 Tab 键顺序中排除一个元素。

So if i have the following

所以如果我有以下几点

<input type=text name=username>
<input type=text name=password>
<input type=button name=forgotpassword>
<input type=submit name=login>

I'm aware that I can use tabindex as 1,2,3,4 but i don't want to have to number all the fields. My application is dynamically creating the fields.

我知道我可以将 tabindex 用作 1,2,3,4,但我不想对所有字段进行编号。我的应用程序正在动态创建字段。

Thanks

谢谢

Jason

杰森

回答by Marko

Setting the tabindexto -1will render an element untabbable (if that's a word) :)

将 设置tabindex-1将使元素不可制(如果这是一个词):)

<input type="text" name="username" tabindex="-1" />