Search w3schools.com:

SHARE THIS PAGE

Button type Property

Button Object Reference Button Object

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".

Syntax

buttonObject.type=value

The type property can have one of the following 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)


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The type property is supported in all major browsers.


Example

Example

Return the type of a 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>

Try it yourself »


Button Object Reference Button Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]