input type=submit与type=button

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值