Javascript DOM HTML Input Reset Object get

Introduction

The Input Reset object represents an HTML <input> element with type="reset".

We can access an <input> element with type="reset" via document.getElementById():

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

Click the button to get the text displayed on the reset button.

View in separate window

<!DOCTYPE html>
<html>
<body>
<input type="reset" id="myReset" value="Reset the form">
<button onclick="myFunction()">Test</button>

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

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

</body>
</html>



PreviousNext

Related