Javascript DOM HTML Input Reset name Property

Introduction

Get the value of the name attribute of a Reset button:

var x = document.getElementById("myReset").name;

Click the button to display the value of the name attribute of the Reset button.

View in separate window

<!DOCTYPE html>
<html>
<body>

First name: <input type="text" name="fname">
<input type="reset" name="reset1" id="myReset">
<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {//from w w w  .j av a2  s .c o  m
  var x = document.getElementById("myReset").name;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The name property sets or gets the value of the name attribute of a reset button.

The name attribute will identify form data after submitting to the server.

Only form elements with a name attribute will be passed to the server.

The name property accepts and returns a String type value.




PreviousNext

Related