HTML <button> type 属性
HTML <button> 标签的 type 属性用于设置按钮的类型
请始终为按钮设置 type 属性
Internet Explorer 的默认类型是 "button",而其它浏览器中(包括 W3C 规范)的默认值是 "submit"
语法
<button type="button|submit|reset">
属性值
值 | 描述 |
---|---|
submit | 该按钮是提交按钮(除了 Internet Explorer,该值是其它浏览器的默认值) |
button | 该按钮是可点击的按钮(Internet Explorer 的默认值) |
reset | 该按钮是重置按钮(清除表单数据) |
浏览器支持
所有主流浏览器都支持 type 属性
范例
两个 button 元素,一个是提交按钮,另一个是重置按钮
<form action="/dy/html/getpost" 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>