Change the text displayed on a button:
document.getElementById("myBtn").value = "CSS";
Click the button below to change the text displayed on the input button.
<!DOCTYPE html> <html> <body> Favorite language:/*from w ww . ja v a 2s. c om*/ <input type="button" id="myBtn" value="Javascript"> <button onclick="myFunction()">Test</button> <script> function myFunction() { document.getElementById("myBtn").value = "CSS"; } </script> </body> </html>
The value
property sets or gets the value attribute of an input button.
The value attribute specifies the text displayed on the button.
The value
property accepts and returns a string value.