Javascript DOM HTML Input Reset type Property get

Introduction

Find out which type of form element the Reset button is:

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

Click the button to find out which type of form element the Reset button is.

View in separate window

<!DOCTYPE html>
<html>
<body>

<input type="reset" id="myReset">
<button onclick="myFunction()">Test</button>

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

<script>
function myFunction() {/*from ww  w.  j ava2  s.co m*/
  var x = document.getElementById("myReset").type;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The type property returns which type of form element a reset button is.

For a reset button object, this property will always return "reset".




PreviousNext

Related