如何做一个div“tabbable”? [英] How do you make a div "tabbable"?

查看:126
本文介绍了如何做一个div“tabbable”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些按钮是div元素,我想要使它们可以让用户按下他们键盘上的tab键并在它们之间移动。我尝试在锚标签中封装他们的文本,但它似乎不工作。

I have buttons that are div elements and I want to make them so that it is possible for the user to press the tab key on their keyboard and move between them. I've tried wrapping their text in anchor tags but it doesn't seem to work.

有人有解决方案吗?

推荐答案

向您的div元素添加 tabindex 属性。

Add tabindex attributes to you div elements.

示例:

<div tabindex="1">First</div>
<div tabindex="2">Second</div>

如果您不希望Tab键顺序偏离元素的位置该页面将tabindex设置为0:

Per steveax's comment, if you don't want the tab order to deviate from where the element is in the page, set the tabindex to 0:

<div tabindex="0">First</div>
<div tabindex="0">Second</div>

这篇关于如何做一个div“tabbable”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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