如何使HTML元素不可对焦? [英] How to make an HTML element non-focusable?
问题描述
是否可以使HTML元素不可焦点?
Is it possible to make an HTML element non-focusable?
我明白可以定义可以接收焦点的元素的列表,用户可以通过按Tab键浏览这些元素。我也看到这是由浏览器控制的。
I understand that a list of elements that can receive focus can be defined and that a user can navigate through these elements by pressing a Tab key. I also see that it is up to the browser to control this.
但是也许有一种方法可以使某些元素不能对焦,比如说我想让用户跳过当一个Tab时,一定的锚点标签。
But maybe there is a way to make certain elements non-focusable, say I want a user to skip a certain Anchor tag when pressing a Tab.
推荐答案
<a href="http://foo.bar" tabIndex="-1">unfocusable</a>
负值意味着元素应该是可对焦的,但不能通过顺序键盘导航来访问。
A negative value means that the element should be focusable, but should not be reachable via sequential keyboard navigation.
https ://developer.mozilla.org/nl/docs/Web/HTML/Global_attributes/tabindex
这篇关于如何使HTML元素不可对焦?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!