我用 AngularJS 多次重复一个 HTML block ,我想在每个项目中独立设置焦点顺序。
困扰我的是我不太清楚如何tabindex
应该工作。
浏览器是否应该对整个文档使用 tabindex 属性,或者它的范围在某些情况下可以被认为是区域性的,例如在文档的某个区域内(例如 <form>
元素内)遵循 Tab 键顺序,直到离开该区域?
基本上,我在重复 block 中的元素将有一个固定的 tabindex
值,所以当它们乘以 ng-repeat
会有很多tabindex="1"
和许多tabindex="2"
, ETC。
我可以拥有它并使 taborder 在每个重复的项目中成为区域性的吗?
我一直试图在这里阅读这个东西(我在谷歌上找到它),但我还没有设法找到能回答我问题的东西:http://www.w3.org/TR/html5/editing.html .
这里: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex 我找到了这个声明:
If several elements share the same tabindex, their relative order follows their relative position in the document).
这是否意味着 tabindex
不能是区域性的?
我可以尝试在浏览器中进行试验,但我想知道是否有人知道规范对此有何规定。
我知道一些替代方法来制作 tabindex
Angular 的值是独一无二的,但我想尽可能避免使用它。
最佳答案
Is the browser supposed to use the tabindex attribute for the whole document
是的。
or its scope can be considered regional in some cases
没有。
If several elements share the same tabindex, their relative order follows their relative position in the document).
这是否意味着 tabindex 不能是区域性的?
不,这意味着如果你有
<label><input tabindex="1"> A</label>
<label><input tabindex="2"> B</label>
<label><input tabindex="1"> C</label>
<label><input tabindex="2"> D</label>
……那么顺序就是A(第一个1),C(第二个1),B(第一个2),D(第二个2)。
关于HTML 的 `tabindex` - 它能不能变成 "regional"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33261406/