HTML DOM form 属性
定义和用法
form 属性可返回对包含该按钮的表单的引用。
如果包含该按钮,则返回一个 form 对象,如果未包含该按钮,则返回 null。
语法
- buttonObject.form
实例
下面的例子可返回包含按钮的表单的 id:
- <html>
- <body>
- <form id="form1">
- <input type="button" value="Click me!" id="button1" />
- </form>
- <p>The id of the form containing the button is:
- <script type="text/javascript">
- x=document.getElementById('button1');
- document.write(
x.form.id
);- </script></p>
- </body>
- </html>