Input Button value Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Button

Description

The value property sets or gets the value attribute of an input button, which defines the text displayed on the button.

Set the value property with the following Values

Value Description
text The text displayed on the button

Return Value

A String, representing the text displayed on the input button

The following code shows how to change the text displayed on a button:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

Favorite car://from w ww  .jav  a2 s.c  o m
<input type="button" id="myBtn" value="Volvo">

<button onclick="myFunction()">change the text displayed on the input button</button>

<script>
function myFunction() {
    document.getElementById("myBtn").value = "new value";
}
</script>

</body>
</html>

Related Tutorials