Javascript Reference - HTML DOM Input Reset form Property








The form property gets the form that contains the reset button.

Browser Support

form Yes Yes Yes Yes Yes

Syntax

var v = resetObject.form 

Return Value

A reference to the form element containing the reset button. If the reset button is not in a form, null is returned.





Example

The following code shows how to get the id of the form containing the <input type="reset"> element.


<!DOCTYPE html>
<html>
<body>
<!--from  w ww  .ja  v  a 2  s  .  c  o m-->
<form id="myForm">
  <input type="reset" id="myReset">
</form>
<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 code above is rendered as follows: