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