美文网首页
input标签使用介绍

input标签使用介绍

作者: 王瓷锤 | 来源:发表于2019-11-29 17:35 被阅读0次
  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">


相关文章

网友评论

      本文标题:input标签使用介绍

      本文链接:https://www.haomeiwen.com/subject/nnygwctx.html