type property (button)
Sets or retrieves the type of a button.
With this property you can create the same type of buttons as with the input element, but with a more complex value. The 'submit' and 'reset' values have effect only within a form element.
Syntax:
You can find the related objects in the Supported by objects section below.
This property is read/write.
HTML page for this property: type |
Possible values:
String that sets or retrieves the type of the button.
One of the following values:
Default. Command button. | |||||||
Reset button. The user can reset the contents of a form with this type of button. | |||||||
Submit button. The user can submit (send to the server) the contents of a form with this type of button. |
Default: button.
Example HTML code 1:
This example illustrates the use of the type attribute:
|
||||
<form> <button type="submit">submit</button> <button type="reset">reset</button> </form> |
||||
|
||||
Did you find this example helpful?
|
Example HTML code 2:
This example illustrates the use of the type property:
|
||||
<head> <script type="text/javascript"> function GetButtonType () { var buttons = document.getElementsByTagName ("button"); for (var i = 0; i<buttons.length; i++) { alert ("The " + i + ". button type = " + buttons[i].type); } } </script> </head> <body> <form> <button type="submit">submit</button> <button type="reset">reset</button> </form> <button onclick="GetButtonType ();">Get the type of buttons!</button> </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by objects:
HTML elements:
Related pages:
External links:
User Contributed Comments