源代码 :
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>开源教程(ossoft.cn)</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>
运行结果