Button type Property
Example
Return the type of a button:
var x = document.getElementById("myBtn").type;
Try it Yourself »
Description
The type property sets or returns the type of a button.
Tip: Always specify the type attribute for the button. The default type for Internet Explorer is "button", while in other browsers (and in the W3C specification) it is "submit".
Browser Support
Property | |||||
---|---|---|---|---|---|
type | Yes | Yes | Yes | Yes | Yes |
Syntax
Return the type property:
buttonObject.type
Set the type property:
buttonObject.type = "submit|button|reset"
Property Values
Value | Description |
---|---|
submit | The button is a submit button (this is default for all browsers, except Internet Explorer) |
button | The button is a clickable button (this is default for Internet Explorer) |
reset | The button is a reset button (clears form data) |
Technical Details
Return Value: | A String, representing the button type |
---|
More Examples
Example
Change the type of a button to "submit":
document.getElementById("myBtn").type = "submit";
Try it Yourself »
Example
Change the type of a button to "reset":
document.getElementById("myBtn").type = "reset";
Try it Yourself »
Related Pages
HTML reference: HTML <button> type attribute
❮ Button Object
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.