小白教程
所有教程
关于
Search
172.69.58.215
172.69.58.215
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Coll doc forms”的源代码
本页内容
上一节:
Coll_doc_embeds
下一节:
Met_document_getelementsbyclassname
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:document.forms}}[[Category:dom obj document|20]] = HTML DOM forms 集合 = [[dom obj document|Document 对象]] == 定义和用法 == forms 集合返回当前页面所有表单的数组集合。 == 语法 == <pre> document.forms[].property </pre> == 浏览器支持 == 所有主要浏览器都支持 forms 集合 == 实例 1 == 返回文档中表单数量: <sample title="" desc="" lang="html" hererun="1"> <html> <body> <form name="Form1"></form> <form name="Form2"></form> <form></form> <p>表单数目: <script> document.write(document.forms.length); </script></p> </body> </html> </sample> 以上实例输出结果: <sample title="" desc="" lang="html" hererun="1"> 表单数目: 3 </sample> <run name=""> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>小白教程(xiaobai.wang)</title> </head> <body> <form name="Form1"></form> <form name="Form2"></form> <form></form> <p>表单数目: <script> document.write(document.forms.length); </script></p> </body> </html> </run> == 实例 2 == 返回文档中第一个表单的名称: <sample title="" desc="" lang="html" hererun="1"> <html> <body> <form name="Form1"></form> <form name="Form2"></form> <form></form> <p>第一个表单名称: <script> document.write(document.forms[0].name); </script></p> </body> </html> </sample> 以上实例输出结果: <sample title="" desc="" lang="html" hererun="1"> 第一个表单名称: Form1 </sample> <run name=""> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>小白教程(xiaobai.wang)</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> </run> [[dom obj document|Document 对象]]
返回至“
Coll doc forms
”。
上一节:
Coll_doc_embeds
下一节:
Met_document_getelementsbyclassname