Search w3schools.com:

SHARE THIS PAGE

Input Button value Property

Button Object Reference Button Object

Definition and Usage

The value property sets or returns the value of the value attribute of a button.

The value attribute defines the text that is displayed on the button.

Syntax

Set the value property:

buttonObject.value="value"

Return the value property:

buttonObject.value


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The value property is supported in all major browsers.


Example

Example

Display the text on the button:

<html>
<head>
<script>
function displayResult()
{
var x=document.getElementById("button1").value;
alert(x);
}
</script>
</head>
<body>

<form>
<input type="button" onclick="displayResult()" value="Display text on button" id="button1">
</form>

</body>
</html>

Try it yourself »


Button Object Reference Button Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]