html——input标签介绍

HTML <input> 标签是用于收集用户信息的关键元素。它有多种类型,包括文本、密码、复选框、单选按钮、文件选择等。

以下是一些常用的 <input> 标签类型及其使用示例:

  1. 文本输入:



<input type="text" name="username" placeholder="Enter your username">
  1. 密码输入:



<input type="password" name="password" placeholder="Enter your password">
  1. 单选按钮:



<input type="radio" name="gender" value="male"> Male<br>
<input type="radio" name="gender" value="female"> Female
  1. 复选框:



<input type="checkbox" name="vehicle" value="Bike"> I have a bike<br>
<input type="checkbox" name="vehicle" value="Car"> I have a car
  1. 文件选择:



<input type="file" name="fileToUpload" accept=".jpg, .jpeg, .png">
  1. 提交按钮:



<input type="submit" value="Submit">
  1. 重置按钮:



<input type="reset" value="Reset">
  1. 隐藏字段:



<input type="hidden" name="userId" value="12345">
  1. 图像作为提交按钮:



<input type="image" src="submit.jpg" alt="Submit">
  1. 颜色选择器:



<input type="color" name="favcolor">
  1. 日期选择器:



<input type="date" name="bday">
  1. 月份和年份选择器:



<input type="month" name="bdaymonth">
  1. 周选择器:



<input type="week" name="week_year">
  1. 数字输入,可以设置最小值、最大值和步长:



<input type="number" name="quantity" min="1" max="5" step="1">
  1. 范围选择器:



<input type="range" min="0" max="100" step="10" value="50">
  1. 搜索框:



<input type="search" name="search" placeholder="Search...">
  1. 电话号码输入,自动验证格式:



<input type="tel" pattern="[0-9]{3}-[0-9]{2}-[0-9]{3}">
  1. 时间输入:



<input type="time" name="appt">
  1. 日期时间输入:



<input type="datetime-local" name="meeting">
  1. 输出标签,用于显示计算结果或服务器响应:



<input type="text" readonly name="result" id="result">

每个类型都有其特定的用途和行为,根据需求选择合适的 <input> 类型。

none
最后修改于:2024年08月16日 09:03

评论已关闭

推荐阅读

Vue中使用mind-map实现在线思维导图
2024年08月04日
VUE
Web前端最全Vue实现免密登录跳转的方式_vue怎么样不登录返回首页,最强技术实现
2024年08月04日
VUE
vue3 项目搭建教程(基于create-vue,vite,Vite + Vue)
2024年08月04日
VUE
Vue-颜色选择器实现方案——>Vue-Color( 实战*1+ Demo*7)
2024年08月04日
VUE
Vue项目卡顿慢加载?这些优化技巧告诉你!_vue数据多渲染卡顿
2024年08月04日
VUE
vue中的keep-alive详解与应用场景
2024年08月04日
VUE
Vue、React实现excel导出功能(三种实现方式保姆级讲解)
2024年08月04日
vue-office/docx插件实现docx文件预览
2024年08月04日
VUE
java调用js文件的两种方法(支持V8引擎)
2024年08月04日
JavaScript:解决计算精度问题/mathjs/bignumber.js/big.js/decimal.js
2024年08月04日
两周从爬虫小白变大神 _yjs_js_security_passport
2024年08月04日
JS笔记(对象、函数、数组)
2024年08月04日
Markdown.js:强大的纯JavaScript Markdown解析器
2024年08月04日
Vue项目:js模拟点击a标签下载文件并重命名,URL文件地址下载方法、请求接口下载文件方法总结。
2024年08月04日
vue 父组件怎么获取子组件里面的data数据
2024年08月04日
VUE
个人开发实现AI套壳网站快速搭建(Vue+elementUI+SpringBoot)
2024年08月04日
el-table 表格封装并改造实现单元格可编辑
2024年08月04日
none
nodejs环境下创建vue项目、SSH密钥登陆!!!
2024年08月04日
vue+quill+element-ui实现视频、图片上传及缩放保姆级教程,轻松使用富文本
2024年08月04日
【three.js】22. Imported Models导入模型
2024年08月04日