Button Object
The Button object represents a push button.
For each <button> tag in an HTML document, a Button object is created.
Inside an HTML button element you can put content, like text or images. This is the difference between this element and buttons created with the input element.
Button Object Properties
W3C: W3C Standard.
Property | Description | W3C |
---|---|---|
form | Returns a reference to the form that contains a button | Yes |
name | Sets or returns the value of the name attribute of a button | Yes |
type | Sets or returns the type of a button | Yes |
value | Sets or returns the value of the value attribute of a button | Yes |
Standard Properties, Methods, and Events
The Button object also supports the standard properties, methods, and events.
Button type Property
Button ObjectDefinition 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
The type property is supported in all major browsers.
Example
ExampleReturn the type of a button:
Try it yourself » |