THE WORLD'S LARGEST WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

Button type Property

Button Object Reference Button Object

Example

Return the type of a button:

var x = document.getElementById("myBtn").type;

The result of x will be:

button
Try it Yourself »

Definition and Usage

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

Internet Explorer Firefox Opera Google Chrome Safari

The type property is supported in all major browsers.


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 Reference Button Object