type 属性设置或返回按钮的类型。
提示:请始终为按钮规定 type 属性。IE 浏览器的默认类型是 "button",而在其他浏览器中(以及在 W3C 规范中)是 "submit"。
</>code
- buttonObject.type=value
值 | 描述 |
---|---|
submit | button 是提交按钮(是 IE 之外的所有浏览器的默认值) |
button | button 是可点击的按钮(IE 的默认值) |
reset | button 是重置按钮(清除表单数据) |
所有浏览器都支持 type 属性。
返回按钮的类型:
</>code
- <html>
- <head>
- <script type="text/javascript">
- function alertType()
- {
- alert(
document.getElementById("myButton").type
)- }
- </script>
- </head>
- <body>
- <form>
- <button id="myButton" onClick="alertType()">点击这里</button>
- </form>
- </body>
- </html>
如对本文有疑问,请提交到交流论坛,广大热心网友会为你解答!! 点击进入论坛
Powered by 365建站网 RSS地图 HTML地图
copyright © 2013-2024 版权所有 鄂ICP备17013400号