3.6 KiB
3.6 KiB
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
587d7790367417b2b2512ab1 | Use tabindex to Specify the Order of Keyboard Focus for Several Elements | 0 | 使用tabindex指定多个元素的键盘焦点顺序 |
Description
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>
Instructions
input
并将input
表单控件提交为Tab键顺序中的前两项。将tabindex
属性设置为“1”到搜索input
, tabindex
属性设置为“2”到提交input
。 Tests
tests:
- text: 您的代码应该向搜索<code>input</code>标记添加<code>tabindex</code>属性。
testString: 'assert($("#search").attr("tabindex"), "Your code should add a <code>tabindex</code> attribute to the search <code>input</code> tag.");'
- text: 您的代码应该向提交<code>input</code>标记添加<code>tabindex</code>属性。
testString: 'assert($("#submit").attr("tabindex"), "Your code should add a <code>tabindex</code> attribute to the submit <code>input</code> tag.");'
- text: 您的代码应将搜索<code>input</code>标记上的<code>tabindex</code>属性设置为值1。
testString: 'assert($("#search").attr("tabindex") == "1", "Your code should set the <code>tabindex</code> attribute on the search <code>input</code> tag to a value of 1.");'
- text: 您的代码应将submit <code>input</code>标记上的<code>tabindex</code>属性设置为值2。
testString: 'assert($("#submit").attr("tabindex") == "2", "Your code should set the <code>tabindex</code> attribute on the submit <code>input</code> tag to a value of 2.");'
Challenge Seed
<body>
<header>
<h1>Even Deeper Thoughts with Master Camper Cat</h1>
<nav>
<ul>
<li><a href="">Home</a></li>
<li><a href="">Blog</a></li>
<li><a href="">Training</a></li>
</ul>
</nav>
</header>
<form>
<label for="search">Search:</label>
<input type="search" name="search" id="search">
<input type="submit" name="submit" value="Submit" id="submit">
</form>
<h2>Inspirational Quotes</h2>
<blockquote>
<p>“There's no Theory of Evolution, just a list of creatures I've allowed to live.”<br>
- Chuck Norris</p>
</blockquote>
<blockquote>
<p>“Wise men say forgiveness is divine, but never pay full price for late pizza.”<br>
- TMNT</p>
</blockquote>
<footer>© 2018 Camper Cat</footer>
</body>
Solution
// solution required