Button type 属性
 Button 对象
 Button 对象
定义和用法
type 属性可设置或者返回按钮的类型。
提示: 请始终为按钮规定 type 属性。IE 浏览器的默认类型是 "button",而在其他浏览器中(以及在 W3C 规范中)是 "submit"。
语法
buttonObject.type=value
type 属性可以是以下值:
| 值 | 描述 | 
|---|---|
| submit | button 是提交按钮(是 IE 之外的所有浏览器的默认值) | 
| button | button 是可点击的按钮(IE 的默认值) | 
| reset | button 是重置按钮(清除表单数据) | 
浏览器支持





所有主要浏览器都支持 type 属性。
实例
返回按钮的类型:
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>蜜蜂教程(mifengjc.com)</title>
  <script>
    function alertType() {
      alert(document.getElementById("myButton").type)
    }
  </script>
</head>
<body>
  <button id="myButton" type="button" onclick="alertType()">点我!</button>
</body>
</html>
 Button 对象
 Button 对象