Input Reset name Property - Change the value of the name attribute of a Reset button: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Reset

Description

Input Reset name Property - Change the value of the name attribute of a Reset button:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<form>
First name: <input type="text" name="fname">
<input type="reset" name="reset1" id="myReset">
</form>/*from w  w w.j  av a 2s.  com*/

<button onclick="display()">Display name</button>
<button onclick="change()">Change name</button>

<script>
function display() {
    var x = document.getElementById("myReset").name;
    console.log("The name of the Reset button is: " + x);
}

function change() {
    var x = document.getElementById("myReset").name = "newName";
    console.log("The name was changed to: " + x);
}
</script>

</body>
</html>

Related Tutorials