HTML DOM Button type attribute
Definition and Usage
type property sets or returns the type of buttons.
Tip: Always provisions for the button type attribute.IE browser's default type is "button", while in other browsers (as well as in the W3C specification) is "submit".
grammar
buttonObject.type=value
type attribute can have the following values:
值 | 描述 |
---|---|
submit | button 是提交按钮(是 IE 之外的所有浏览器的默认值) |
button | button 是可点击的按钮(IE 的默认值) |
reset | button 是重置按钮(清除表单数据) |
Browser Support
All major browsers support type attribute.
Examples
Examples
Return type button:
<html>
<head>
<script>
function alertType()
{
alert(document.getElementById("myButton").type)
}
</script>
</head>
<body>
<button id="myButton" type="button" onclick="alertType()">Click Me!</button>
</body>
</html>
<head>
<script>
function alertType()
{
alert(document.getElementById("myButton").type)
}
</script>
</head>
<body>
<button id="myButton" type="button" onclick="alertType()">Click Me!</button>
</body>
</html>
try it"
Button Objects