html表单1:表单基础

表单

网页中的一个交互区域

form表单标签属性

action:选择将表单传递给谁处理

target:选择跳到那个页面(_self/_blank...)

method:选择请求方式

input输入控件

type="text"表示为输入框 ,name属性中传入接收方规定的参数

value代表输入框中的默认值

maxlength属性代表输入的最大长度

button按钮控件
代码如下
html 复制代码
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <form action="https://www.baidu.com/s" target="_self" method="get">
        <!-- action选择将表单传给谁处理 -->
        <!-- target选择跳到哪个页面 -->
        <!-- method选择请求方式 -->
        <input type="text" name="wd" id="">
        <!-- 输入框 name中需要传递接收方规定的参数 -->
        <button>搜索</button>
        <!-- 按钮 -->
    </form>
    <form action="https://search.jd.com/search" target="_blank">
        <!-- 选择将表单传给谁处理 -->
        <input type="text" name="keyword" id="">
        <!-- 输入框 name中需要传递接收方规定的参数 -->
        <button>搜索</button>
        <!-- 按钮 -->
    </form>
    <form action="">
        账户: <input type="text" name ="account" value="ooo" maxlength="10"><br>
        密码: <input type="password" name ="password" value="123"><br>
        <button>确认</button>
    </form>
</body>
</html>
相关推荐
_codemonster13 分钟前
Vue中的ref和reactive到底在干嘛
前端·javascript·vue.js
IT_陈寒26 分钟前
为什么我的JavaScript闭包总是漏掉那个变量?
前端·人工智能·后端
两只羊ovo1 小时前
前端八股之 storage & this:两个最容易卡住的点,一次讲透
前端
用户921080262861 小时前
Bubble 打字机效果实践:从项目配置到源码实现
前端
张元清1 小时前
React useEventListener Hook:类型安全的 DOM 事件监听 (2026)
javascript·react.js
weixin_461408581 小时前
npm npx yarn
开发语言·前端·javascript
四千岁2 小时前
RAG系统中的分块
前端·javascript·后端
START_GAME2 小时前
MSSQL$SQL2016
java·服务器·前端
Captaincc2 小时前
Show me your works & token -稀土掘金上线内测作品广场和用量统计
前端·掘金社区·vibecoding