input
标签
1. type=button
定义可点击的按钮(通常与 JavaScript 一起使用来启动脚本)。
<input type="button">
elements have no default behavior (their cousins,<input type="submit">
and<input type="reset">
are used to submit and reset forms, respectively). To make buttons do anything, you have to write JavaScript code to do the work.
(来自mdn:https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/button)
菜鸟链接 https://www.runoob.com/tags/att-input-type.html
2. type=submit
用于提交表单按钮
<input type="submit">
按钮用于提交form
表单. 如果你想要创建一个自定义的按钮,然后通过JavaScript
自定义按钮的行为,你需要使用 <input type="button">
, 或者使用更好的<button>
元素.
如果你选择使用<button>
在你的form
表单里创建按钮, 请记住: 它只是在<form>
内部的 <button>
, 应该被当作 "submit"
按钮来处理。 所以你应该有一个明确指定哪一个按钮是提交按钮的习惯。
(来自mdn:https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/input/submit)
button type
The default behavior of the button. Possible values are:
submit
: The button submits the form data to the server. This is the default if the attribute is not specified, or if the attribute is dynamically changed to an empty or invalid value.
reset
: The button resets all the controls to their initial values, like<input type="reset">
.
button
: The button has no default behavior and does nothing when pressed. It can have client-side scripts associated with the element’s events, which are triggered when the events occur.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button