Button value Property
Example
Return the value of the value attribute of a button:
var x = document.getElementById("myBtn").value;
Try it Yourself »
Description
The value property sets or returns the value of the value attribute of a button.
The value attribute specifies the underlying value that is associated with a button.
Important: 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, while other browsers will submit the content of the value attribute.
Browser Support
Property | |||||
---|---|---|---|---|---|
value | Yes | Yes | Yes | Yes | Yes |
Syntax
Return the value property:
buttonObject.value
Set the value property:
buttonObject.value = text
Property Values
Value | Description |
---|---|
text | The initial value of the button |
Technical Details
Return Value: | A String, representing the underlying value that is associated with the button |
---|
More Examples
Example
Change the value of the value attribute of a button:
document.getElementById("myBtn").value = "newButtonValue";
Try it Yourself »
Related Pages
HTML reference: HTML <button> value attribute
❮ Button Object
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.