input标签使用介绍

  1. 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>

  1. type为“password”,在输入框中输入的数据会自动转换为圆点

<input type="password" name=password>


  1. 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>


  1. 若输入框中有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'>


  1. type为“hidden”,这个隐藏域不会被用户看见,但是会在http请求内容中一并提交给服务器,它可以确保后端收到的数据来自于自己的网页而非黑客知道后端地址后传送的数据。

<input type="hidden" name="xxx" value="abc">

  1. type为“submit”,作用于submit标签相同

<input type="submit" value="abc">


最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容