Javascript examples for DOM HTML Element:Input Button
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 |
A String, representing the text displayed on the input button
The following code shows how to change the text displayed on a button:
<!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>