HTML|按钮和多选框
1.多选框
和单选框相比,就是将type属性从radio改成了checkbox,比如我们建立一个爱好的多项选择:
有睡觉,篮球,足球和编程:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>按钮和多选框</title>
</head>
<body>
<!--
多选框:
checkbox
value也是必须要有的
name也需要是一样的
和性别的单选框相比,就是type从radio改成了checkbox
-->
<p>
爱好(多选):
<input type="checkbox" value="sleep" name="hobby">睡觉
<input type="checkbox" value="basketball" name="hobby">篮球
<input type="checkbox" value="soccer ball" name="hobby">足球
<input type="checkbox" value="coding" name="hobby">编程
</p>
</body>
</html>
2.按钮
将input的type改为button即可,也要有name和value:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>按钮和多选框</title>
</head>
<body>
<!--
多选框:
checkbox
value也是必须要有的
name也需要是一样的
和性别的单选框相比,就是type从radio改成了checkbox
-->
<p>
爱好(多选):
<input type="checkbox" value="sleep" name="hobby">睡觉
<input type="checkbox" value="basketball" name="hobby">篮球
<input type="checkbox" value="soccer ball" name="hobby">足球
<input type="checkbox" value="coding" name="hobby">编程
</p>
<!--
按钮:
将input的type改为button即可,要为其设置name和value
-->
<p>
<input type="button" name="bt" value="按钮">
</p>
</body>
</html>
可以看到生成了一个按钮,但是这个按钮点击了过后肯定是不会有任何响应的,因为仅仅只是一个按钮,没有其他任何内容。
人生没有白走的路,每一步都算数!