<html>
<body>
<p>请点击输入按钮返回所属表单的 id。</p>
<form id="myForm">
<input type="button" onclick="myFunction()" id="myBtn" value="试一试">
</form>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myBtn").form.id;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>