Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<body>
<p>Click the input button to return the id of the form it belongs to.</p>
<form id="myForm">
<input type="button" onclick="myFunction()" id="myBtn" value="Try it">
</form>
<p id="demo"></p>
<script>
function myFunction() {
  var x = document.getElementById("myBtn").form.id;
  document.getElementById("demo").innerHTML = x;
}
</script>
</body>
<!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_inputbutton_form by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 21 Dec 2022 18:16:54 GMT -->
</html>