Button valueProperty
Button Object
Definition and Usage
The value property sets or returns the value of the value attribute of a button.
The value attribute specifies the text displayed on the button.
Important:If you use the button element in an HTML form, different browsers will display different values. Internet Explorer displays the value between the <button> and </button> tags, while other browsers display the value in the value attribute. In an HTML form, you can use the input element to display a button.
Syntax
buttonObject.value=value
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the value property.
Example
Example
Return the text displayed on the button:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example (example.com)</title>
</head>
<body>
<input type="button" id="button1" value="Click me!">
<p>The button's text:
<script>
document.write(document.getElementById("button1").value);
</script></p>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Example (example.com)</title>
</head>
<body>
<input type="button" id="button1" value="Click me!">
<p>The button's text:
<script>
document.write(document.getElementById("button1").value);
</script></p>
</body>
</html>
Try it Yourself »
Button Object Other Extensions