Button value attribute
Definition and usage
value
Attribute sets or returns the value of the button's value attribute value.
value attribute Specify the base value associated with the button.
Important reminder:If you use the <button> element in an HTML <form>, different browsers will submit different values:
- Internet Explorer will submit the text between the <button> and </button> tags
- Other browsers will submit the content of the value attribute
Instance
Example 1
Return the value of the button's value attribute:
var x = document.getElementById("myBtn").value;
Example 2
Change the value of the button's value attribute:
document.getElementById("myBtn").value = "newButtonValue";
Syntax
Return value attribute:
buttonObject.value
Set value attribute:
buttonObject.value = text
Attribute Value
Value | Description |
---|---|
text | The initial value of the button. |
Technical Details
Return Value: | A string value representing the base value associated with the button. |
---|
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |
Related Pages
HTML Reference Manual:HTML <button> value Attribute