HTML DOM form 属性

定义和用法

form 属性可返回对包含选项的表单的引用。

语法

  1. optionObject.form

实例

  1. <html>
  2. <body>
  3.  
  4. <form id="myForm">
  5. <select id="mySelect">
  6. <option id="apple">Apple</option>
  7. <option id="orange">Orange</option>
  8. <option id="pineapple">Pineapple</option>
  9. <option id="banana">Banana</option>
  10. </select>
  11. </form>
  12.  
  13. <p>The id of the form is:
  14. <script type="text/javascript">
  15. document.write(document.getElementById("apple").form.id)
  16. </script>
  17. </p>
  18.  
  19. </body>
  20. </html>