input标签type属性值不同,则功能不同。
<input type="...">
type属性值 | 说明 |
---|---|
text | 文本框,用于输入单行文本 |
password | 密码框 |
radio | 单选框 |
checkbox | 多选框 |
file | 上传文件 |
单选框 radio
常用属性
属性名 | 作用 | 特殊说明 |
---|---|---|
name | 控件名称 | 控件分组,同组只能选中一个(单选功能) |
checked | 默认选中 | 属性名和属性值相同,简写为一个单词 |
<input type="radio" name="gender" cheched>男
<input type="radio" name="gender">女
多选框 checkbox
多选框也叫复选框。
默认选中:checked
<input type="checkbox" checked>唱
<input type="checkbox">跳
<input type="checkbox" checked>rap
上传文件 file
默认情况下,文件上传表单控件只能上传一个文件,添加multiple属性可以实现文件多选功能。
<input type="file" multiple>