Return the type of a button:
The result of x will be:
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".
The type property is supported in all major browsers.
Return the type property:
Set the type property:
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) |
Return Value: | A String, representing the button type |
---|
Change the type of a button to "submit":
Change the type of a button to "reset":
HTML reference: HTML <button> type attribute