HTML DOM forms collection
HTML DOM forms Collection
Definition and usage
The forms collection returns an array collection of all forms on the current page.
Syntax
document.forms[].property
Browser support
All major browsers support forms collection
Examples
Examples
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> </head> <body> <form name="Form1"></form> <form name="Form2"></form> <form></form> <p>表单数目: <script> document.write(document.forms.length); </script></p> </body> </html>
Run Instance»
Click the "Run Instance" button to view the online instance
Instance
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> </head> <body> <form name="Form1"></form> <form name="Form2"></form> <form></form> <p>第一个表单名称: <script> document.write(document.forms[0].name); </script></p> </body> </html>
Run Instance»
Click the "Run Instance" button to view the online instance