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

Javascript examples for DOM HTML Element:Input Submit

Description

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

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<input type="submit" name="submit1" id="mySubmit">

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

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

function change() {/*from   w w  w .j a  v  a2  s.c  o  m*/
    var x = document.getElementById("mySubmit").name = "newName";
    console.log("The name was changed to: " + x);
}
</script>

</body>
</html>

Related Tutorials