Input Button value Attribute

Definition and Usage

value Sets or returns the value of the value attribute of the input button.

The HTML value attribute defines the text displayed on the button.

See also:

HTML Reference Manual:HTML <input> value Attribute

Example

Example 1

Change the text displayed on the button:

document.getElementById("myBtn").value = "BMW";

Try It Yourself

Example 2

Get the text displayed on the button:

var x = document.getElementById("myBtn").value;

Try It Yourself

Syntax

Return value attribute:

buttonObject.value

Set value attribute:

buttonObject.value = text

Attribute Value

Value Description
text Text displayed on the button.

Technical Details

Return Value: A string value representing the text displayed on the input button.

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support