使HTML元素不可聚焦 [英] Make an HTML element non-focusable

查看:232
本文介绍了使HTML元素不可聚焦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使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 时的某个< a> 标签。

But maybe there is a way to make certain elements non-focusable, say I want a user to skip a certain <a> 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.

另请参见: developer.mozilla.org

这篇关于使HTML元素不可聚焦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆