Javascript DOM HTML Input Reset form Property get

Introduction

Get the id of the form containing the <input type="reset"> element:

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

Click the button to display the id of the form the Reset button belongs to.

View in separate window

<!DOCTYPE html>
<html>
<body>

<form id="myForm">
  <input type="reset" id="myReset">
</form>/*from  w  ww  .  j  a  v a2  s .  c  o  m*/
<button onclick="myFunction()">Test</button>

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

<script>
function myFunction() {
  var x = document.getElementById("myReset").form.id;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The form property returns a reference to the form that contains the reset button.

This property returns a form object on success.

This property is read only.

If the reset button is not in a form, null is returned




PreviousNext

Related