Change the value of the name attribute of a Reset button:
document.getElementById("myReset").name = "newName";
Click the buttons to display and change the value of the name attribute of the Reset button.
<!DOCTYPE html> <html> <body> <form> First name: <input type="text" name="fname"> <input type="reset" name="reset1" id="myReset"> </form>//ww w . j a va2s.c o m <p id="demo"></p> <button onclick="display()">Display name</button> <button onclick="change()">Change name</button> <script> function display() { var x = document.getElementById("myReset").name; document.getElementById("demo").innerHTML = "The name of the Reset button is: " + x; } function change() { var x = document.getElementById("myReset").name = "newName"; document.getElementById("demo").innerHTML = "The name was changed to: " + x; } </script> </body> </html>