input

2022-10-15

input标签类型:button是一个没有任何功能的按钮,需要用javascript加上动作才可以使用。功能简单,比起<button></button>是一个功能强大的按钮,更美观。

<input type="button" />

 

input标签类型:checkbox是多选框

用label绑定input。

<label for="check">

  <input type="checkbox" >

</label>

 

input标签类型:file能指定电脑中的文件。

<input type="file">

file有2个属性分别是:

multiple【多个文件可以被同时选中. 只要用户所在的平台允许 (摁住 shift 或者 ctrl), 用户可以选择多个文件】写法如下:

<input type="file" id="file" name="file" multiple />

accept【可以指定上传文件的格式。例如指定是.jpg格式就只有jpg图片可见】

<form action="">
  <label for="file">
    <input type="file" id="file" name="file" accept=".jpg,.jpeg,.png" />
  </label>
</form>

 

input标签类型:hidden【允许 web 开发者存放一些用户不可见、不可改的数据,在用户提交表单时,这些数据会一并发送出。比如,正被请求或编辑的内容的 id,或是一个唯一的安全令牌。这些隐藏的 <input> 元素在渲染完成的页面中完全不可见,而且没有方法可以使它重新变为可见。】

<input type="hidden" name="ez" id="ez" value="qwer13214" />

《input.doc》

下载本文的Word格式文档,以方便收藏与打印。