设置按钮的tabindex不起作用 [英] set tabindex for button not working

查看:525
本文介绍了设置按钮的tabindex不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在表单上没有几个控件.我必须以与其在HTML上创建的顺序不自然的顺序设置tabIndex.在fag末尾有一个按钮,并且tabIndex仅在此元素上没有设置(它从未关注).

I have few controls on a form. I have to set the tabIndex in an order that is not natural to their order of creation on HTML. There is a button at the fag end and the tabIndex is not getting set (it's never focussed) only on this element.

<button id="btnSave" tabindex = "86" title='click here'>Submit Here</button>

可能是什么原因?

感谢您的帮助.

推荐答案

Tabindex最佳做法

Tabindex Best Practices

很常见,我建议不要为Tabindex设置任何增量值,因为如果遵循此规则,则对于网页中的任何字段/组件,我们都需要为即将到来的字段保持相同的tabindex增量值,而且我们大多根据某些条件显示/隐藏字段/组件,以免选项卡索引无法始终工作.

Commonly, I would suggest that do not set Tabindex with any incremental values because for any fields/components in your web page if we follow this rule then we need to maintain the same tabindex incremental values for upcoming fields too and also we mostly show/hide the fields/components based on some conditions so that time the tab index will not work consistently.

我强烈建议最佳实践是,我们不应该使用大于0的Tabindex,而在需要的地方仅使用Tabindex -1和0

I strongly suggest the best practice is that we should not use Tabindex Greater than 0 and use only Tabindex -1 and 0 wherever required

tabindex =-1"

设置tabindex =-1"允许您使用脚本设置元素的焦点,但不能将其置于页面的标签顺序中.当您需要将焦点转移到通过脚本或用户操作之外更新的内容时,这非常方便.

Setting tabindex="-1" allows you to set an element’s focus with the script, but does not put it in the tab order of the page. This is handy when you need to move focus to something you have updated via script or outside of user action.

tabindex ="0"

设置tabindex ="0"将使用一个元素并使它可聚焦.它不会按跳位顺序设置元素的位置,而只是允许用户按照元素在DOM中的位置确定的顺序来聚焦元素.

Setting tabindex="0" will take an element and make it focusable. It doesn’t set the element’s position in the tab order, it just allows a user to focus the element in the order determined by its location with the DOM.

tabindex ="1" (或任何大于0的值)

tabindex="1" (or any value > 0)

请勿设置tabindex ="1"或任何大于零的值(或任何正值).

Do not set a tabindex="1" or any value greater than zero (or any positive value).

这篇关于设置按钮的tabindex不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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