HTML DOM form 属性

定义和用法

form 属性可返回对包含该确认按钮的表单的引用。

若成功,该属性返回一个表单对象。

语法

  1. submitObject.form

实例

下面的例子将返回该确认按钮所属的表单的 id:

  1. <html>
  2. <body>
  3.  
  4. <form id="form1">
  5. <input type="submit" id="submit1" />
  6. </form>
  7.  
  8. <p>The id of the form containing the submit button is:
  9. <script type="text/javascript">
  10. x=document.getElementById('submit1');
  11. document.write(x.form.id);
  12. </script></p>
  13.  
  14. </body>
  15. </html>