返回到:DOM 对象:HTML DOM Document 对象
forms 集合返回当前页面所有表单的数组集合。
document.forms[].property
所有主要浏览器都支持 forms 集合
返回文档中表单数量:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Web176教程网(web176.com)</title> </head> <body> <form name="Form1"></form> <form name="Form2"></form> <form></form> <p>表单数目: <script> document.write(document.forms.length); </script></p> </body> </html>
返回文档中第一个表单的名称:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Web176教程网(web176.com)</title> </head> <body> <form name="Form1"></form> <form name="Form2"></form> <form></form> <p>第一个表单名称: <script> document.write(document.forms[0].name); </script></p> </body> </html>