HTML <button> type 属性


实例

两个 button 元素,一个是提交按钮,另一个是重置按钮:

  1. <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="Submit">Submit</button>
      <button type="reset" value="Reset">Reset</button>
    </form>
运行一下 »

浏览器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

所有主流浏览器都支持 type 属性。

定义和用法

type 属性规定按钮的类型。

提示: 请始终为按钮规定 type 属性。Internet Explorer 的默认类型是 "button",而其他浏览器中(包括 W3C 规范)的默认值是 "submit"。

HTML 4.01 与 HTML5之间的差异

NONE.

语法

  1. <button type="button|submit|reset">

属性值

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