源代碼
點擊運行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>教程</title> </head> <body> <form id="form1"> <button id="button1" type="button">點我!</button> </form> <p>含有按鈕的表單的ID: <script> document.write(document.getElementById("button1").form.id); </script></p> </body> </html>
運行結果