input标签使用介绍
- type为“radio”时代表在同name的checkbox中进行单选
<form action="/abc" method='get'>
<div class="hobby">
<input type="radio" name='hobby' value='reading'>阅读
<input type="radio" name='hobby' value='music'>音乐
<input type="radio" name='hobby' value='dance'>跳舞
</div>
<div class="hobby1">
<input type="radio" name='hobby1' value='reading'>阅读
<input type="radio" name='hobby1' value='music'>音乐
<input type="radio" name='hobby1' value='dance'>跳舞
</div>
</form>
![]()
- type为“password”,在输入框中输入的数据会自动转换为圆点
<input type="password" name=password>
![]()
- type为“checkbox”时,只要框中有checked属性,不论其值为什么都会勾选
<div class='ok'>
<input type="checkbox" checked>
<input type="checkbox" checked='false'>
<input type="checkbox" checked='true'>
<input type="checkbox" checked=''>
</div>
![]()
- 若输入框中有disabled,与第三条类似,不论disabled是否设置值,输入框都是失效的
<input type="text" placeholder=“输入文本”>
<input type="text" disabled>
<input type="text" disabled='false'>
<input type="text" disabled='true'>
<input type="text" disabled=''>
![]()
5.type为“file”会自动在本地选择文件上传,并可以规定文件格式
<input type="file" accept='image/png'>
![]()
- type为“hidden”,这个隐藏域不会被用户看见,但是会在http请求内容中一并提交给服务器,它可以确保后端收到的数据来自于自己的网页而非黑客知道后端地址后传送的数据。
<input type="hidden" name="xxx" value="abc">
- type为“submit”,作用于submit标签相同
<input type="submit" value="abc">
![]()