表单 HTML button 标签

<button></button>

定义按钮,在 <button> 元素内部,可以放置文本、图像等内容,这是该元素与使用 <input> 元素创建的按钮之间的不同之处
提示:请始终为 <button> 元素规定 type 属性,否则就是个花瓶。

属性 描述
autofocus autofocus 页面加载时 <input>元素应该自动获得焦点
disabled disabled 定义禁用的 <input> 元素
form form_id 定义 <input>所属的一个或多个表单
formaction URL 规定当提交表单时向何处发送表单数据。覆盖 form 元素的 action 属性。该属性与 type=“submit” 配合使用。
formmethod get post 规定用于发送表单数据的 HTTP 方法。覆盖 form 元素的 method 属性。该属性与 type=“submit” 配合使用。
formnovalidate formnovalidate 布尔属性,当表单提交时不进行验证。覆盖 form 元素的 novalidate 属性。该属性与 type=“submit” 配合使用。
formtarget _blank _self _parent _top framename 规定表示提交表单后,在哪里显示接收到响应的名称或关键词,在何处打开 action URL。覆盖 form 元素的 target 属性。该属性与 type=“submit” 配合使用。
name text 按钮的名称。在 JavaScript 中引用元素,或者在表单提交后引用表单数据。(PS:只有设置了 name 属性的表单元素才能在提交表单时传递它们的值)。
value text 按钮的初始值。可由脚本进行修改
type button reset submit 按钮的类型

submit 提交(除了 Internet Explorer,该值是其他浏览器的默认值)。
button 可点击(Internet Explorer 的默认值),可用于设置函数。
reset 重置(清除表单数据)。

<form action="demo_form.html" method="get">
  First name: <input type="text" name="fname"><br>
  Last name: <input type="text" name="lname"><br>
  <button type="submit" value="提交">提交</button>
  <button type="reset" value="重置">重置</button>
</form>

猜你喜欢

转载自blog.csdn.net/qq_43662261/article/details/85062112