x
 
<!DOCTYPE html>
<html>
<body>
<form id="myForm">
复选框:<input type="checkbox" id="myCheck">
</form>
<p>请点击“试一试”按钮,显示复选框所属表单的 id。</p>
<button onclick="myFunction()">试一试</button>
<p id="demo"></p>
<script>
function myFunction() {
  var x = document.getElementById("myCheck").form.id;
  document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>