继续。
如题,这个例子就叫新的输入类型:
代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
</head>
<body>
<script type="text/javascript">
// 注意:并不是所有的主流浏览器都支持新的input类型,不过您已经可以在所有主流的浏览器中使用它们了。
// 即使不被支持,仍然可以显示为常规的文本域。
// HTML5 拥有多个新的表单输入类型。这些新特性提供了更好的输入控制和验证。
</script>
<p>选择一个喜欢的颜色把!<input type="color" name="" id="" value="" /></p>
<p>挑选一个时间把!<input type="date" name="" id="" value="" /></p>
<p>再挑一个UTC时间把!<input type="datetime" name="" id="" value="" /></p>
<p>再挑一个不讲究时区的时间把!<input type="datetime-local" name="" id="" value="" /></p>
<form action="" method="post">
接下来填个邮箱地址把:<input type="email" name="" id="" value="" />
<input type="submit" value="提交"/>
</form>
<p>生日 (月和年): <input type="month" name="bdaymonth"></p>
<form action="" method="post">
数量 ( 1 到 5 之间 ): <input type="number" name="quantity" min="1" max="5">
<input type="submit" value="提交"/>
</form>
<form action="" method="post">
<input type="range" name="points" min="0" max="10">
<input type="submit" value="提交"/>
</form>
<script type="text/javascript">
//
</script>
</body>
</html>
运行结果:
同样知识非常简单的见识一下新的输入类型,分别有颜色,日期,UTC日期,本地时间、邮箱地址、月历、指定范围的数字和数字(进度条)。
具体应用,大概就是value提供默认值,id用来给JavaScript调用或者HTML文档调用
之类的吧。