tabindex
属性还指定元素的确切Tab键顺序。当属性的值被设置为1或更高的正数时,可以实现这一点。设置tabindex =“1”将首先将键盘焦点放在该元素上。然后循环显示指定tabindex
值(2,3等)的序列,然后移至默认值和tabindex="0"
项。重要的是要注意,当以这种方式设置Tab键顺序时,它会覆盖默认顺序(使用HTML源)。这可能会使期望从页面顶部开始导航的用户感到困惑。在某些情况下,这种技术可能是必要的,但就可访问性而言,在应用之前要小心。这是一个例子: <div tabindex="1">I get keyboard focus, and I get it first!</div>
<div tabindex="2">I get keyboard focus, and I get it second!</div>
input
并将input
表单控件提交为Tab键顺序中的前两项。将tabindex
属性设置为“1”到搜索input
, tabindex
属性设置为“2”到提交input
。 input
标记添加tabindex
属性。
testString: 'assert($("#search").attr("tabindex"), "Your code should add a tabindex
attribute to the search input
tag.");'
- text: 您的代码应该向提交input
标记添加tabindex
属性。
testString: 'assert($("#submit").attr("tabindex"), "Your code should add a tabindex
attribute to the submit input
tag.");'
- text: 您的代码应将搜索input
标记上的tabindex
属性设置为值1。
testString: 'assert($("#search").attr("tabindex") == "1", "Your code should set the tabindex
attribute on the search input
tag to a value of 1.");'
- text: 您的代码应将submit input
标记上的tabindex
属性设置为值2。
testString: 'assert($("#submit").attr("tabindex") == "2", "Your code should set the tabindex
attribute on the submit input
tag to a value of 2.");'
```
“There's no Theory of Evolution, just a list of creatures I've allowed to live.”
- Chuck Norris
```“Wise men say forgiveness is divine, but never pay full price for late pizza.”
- TMNT