html - 表单按钮,无类型提交,提交表单
问题描述
我知道按钮上的 type="submit" 与输入相同。
这里的问题是:如果我有一个表单,没有任何提交按钮/输入,为什么会触发提交?
<form method="post" action="lf-p1-02a.html">
<div class="d-flex justify-content-center flex-wrap buttonCheck multiButtonCheck">
<button class="col-md-6 formButton bigButton">
<span>Button 1</span>
</button>
<button class="col-md-6 formButton bigButton">
<span>Button 2</span>
</button>
<button class="col-md-6 formButton bigButton">
<span>Button 3</span>
</button>
<button class="col-md-6 formButton bigButton">
<span>Button 4</span>
</button>
</div>
<div class="d-flex justify-content-center formFooter">
<button class="mainBtn">Continue</button>
</div>
</form>
小提琴: http: //jsfiddle.net/36zsa1t8/(我知道没有任何样式)。
表单中的 Continue 按钮实际上是提交它,进入下一页。
代码上没有 JavaScript。
知道为什么会这样吗?
解决方案
正如此答案中所解释的,对于大多数浏览器,默认type
值为。button
submit
推荐阅读
- c# - C#如何在datagridview(SQL)中显示数据库表的项目
- r - 按组删除一个特定字符串前面的 NA,但保留在另一个特定字符串前面
- node.js - Firebase 函数从 URL 获取参数
- firebase - 如何使用 Firebase Admin SDK(服务器端)验证电子邮件/密码凭据?
- javascript - 如何在 Node js 后端服务器中创建一个对象并将其传递给 Angular 2 前端
- javascript - 在 OpenLayers 中安装 arc.js
- c# - 从 MVC 中的 Genric Handler 获取 Ienumrable 类型响应
- c# - 无法将 TFS 2015 与 SonarQube 集成
- oracle - Oracle Apex 行问题
- javascript - 如果元素不存在,如何使用 JS 删除类?