Change the value attribute of a button:
document.getElementById("myBtn").value = "newButtonValue";
Click on "My Button" to display its value attribute.
Click on "Test" to change the value attribute of "My Button".
<!DOCTYPE html> <html> <body> <button id="myBtn" name="myname" value="myvalue" onclick="alert(this.value)">My Button</button> <button onclick="myFunction()">Test</button> <script> function myFunction() {/*from ww w . j a v a 2s . c o m*/ document.getElementById("myBtn").value = "newButtonValue"; } </script> </body> </html>