2.7 KiB
2.7 KiB
id | title | challengeType | videoUrl | forumTopicId | localeTitle |
---|---|---|---|---|---|
587d778b367417b2b2512aa8 | Add an Accessible Date Picker | 0 | https://scrimba.com/c/cR3bRbCV | 301008 | 添加可访问的日期选择器 |
Description
input
标签,它可以用来创建多种表单控件。它的type
属性指定了所要创建的input
标签类型。
在以前的挑战中,你可能已经见过text
与submit
类型的input
标签,HTML5 引入了date
类型来创建时间选择器。依赖于浏览器的支持,当点击input
标签时,时间选择器会显示出来,这可以让用户填写表单更加容易。
对于旧版本的浏览器,type
属性的默认值是text
。这种情况下,可以利用label
标签或者占位文本来提示用户input
标签的输入类型为日期。
举个例子:
<label for="input1">Enter a date:</label>
<input type="date" id="input1" name="input1">
Instructions
input
标签,其type
属性值为 date,id
属性为 pickdate,name
属性为 date。
Tests
tests:
- text: '你的代码中应该有 1 个<code>input</code>标签。'
testString: assert($('input').length == 2);
- text: '你的<code>input</code>标签的<code>type</code>属性值应该为 date。'
testString: assert($('input').attr('type') == 'date');
- text: '你的<code>input</code>标签的<code>id</code>属性值应该为 pickdate。'
testString: assert($('input').attr('id') == 'pickdate');
- text: '你的<code>input</code>标签的<code>name</code>属性值应该为 date。'
testString: assert($('input').attr('name') == 'date');
Challenge Seed
<body>
<header>
<h1>Tournaments</h1>
</header>
<main>
<section>
<h2>Mortal Kombat Tournament Survey</h2>
<form>
<p>Tell us the best date for the competition</p>
<label for="pickdate">Preferred Date:</label>
<!-- Add your code below this line -->
<!-- Add your code above this line -->
<input type="submit" name="submit" value="Submit">
</form>
</section>
</main>
<footer>© 2018 Camper Cat</footer>
</body>
Solution
// solution required