js获取页面表单的个数
来源:懂视网
责编:小采
时间:2020-11-27 20:32:08
js获取页面表单的个数
js获取页面表单的个数: Click here function function1() { var m = document.forms.length; console.log(There are +m+ forms in this document) } 本实例中,我们创建了3个form表单,然后使用js的document.forms.length来获取表单个数,最后在控制台中输出这个值。最终输出结果为“There are 3 forms in this docu
导读js获取页面表单的个数: Click here function function1() { var m = document.forms.length; console.log(There are +m+ forms in this document) } 本实例中,我们创建了3个form表单,然后使用js的document.forms.length来获取表单个数,最后在控制台中输出这个值。最终输出结果为“There are 3 forms in this docu

本实例中,我们创建了3个form表单,然后使用js的document.forms.length来获取表单个数,最后在控制台中输出这个值。最终输出结果为“There are 3 forms in this document”。
你可以把代码复制到这个页面运行一下。
js获取页面表单的个数
js获取页面表单的个数: Click here function function1() { var m = document.forms.length; console.log(There are +m+ forms in this document) } 本实例中,我们创建了3个form表单,然后使用js的document.forms.length来获取表单个数,最后在控制台中输出这个值。最终输出结果为“There are 3 forms in this docu