js如何获取表单元素个数
来源:懂视网
责编:小采
时间:2020-11-27 20:32:07
js如何获取表单元素个数
js如何获取表单元素个数: function showNumElements(){ console.log(There are + document.form1.length + elements in this document); } 首先获取表单对象,然后通过length属性获取表单元素的个数。输出结果为:“There are 4 elem
导读js如何获取表单元素个数: function showNumElements(){ console.log(There are + document.form1.length + elements in this document); } 首先获取表单对象,然后通过length属性获取表单元素的个数。输出结果为:“There are 4 elem

首先获取表单对象,然后通过length属性获取表单元素的个数。输出结果为:“There are 4 elements in this document”。
你可以把代码复制到这个页面运行一下。
js如何获取表单元素个数
js如何获取表单元素个数: function showNumElements(){ console.log(There are + document.form1.length + elements in this document); } 首先获取表单对象,然后通过length属性获取表单元素的个数。输出结果为:“There are 4 elem