<html>
<body>
< language=\" \">
function showNumElements(){
console.log(\"There are \" + document.form1.length + \" elements in this document\");
}
</ >
<form name=\"form1\">
Enter First Name:
<input type=\"text\" size=15><br>
Enter Last Name:
<input type=\"text\" size=20><br>
Enter address:
<input type=\"text\" size=40><br><br>
<input type=\"button\" value=\"Submit\" =showNumElements()>
</form>
</body>
</html>
首先获取表单对象,然后通过length属性获取表单元素的个数。输出结果为:“There are 4 elements in this document”。
你可以把代码复制到这个页面运行一下。
继续阅读与本文标签相同的文章
-
剧情反转?美企主动购买华为5G技术,华为成赞赏排行榜第一名!
2026-05-14栏目: 教程
-
城市数字化后,新一代内生安全系统可全方位保护
2026-05-14栏目: 教程
-
谷歌也来“唱衰”5G,5G手机只会徒增功耗?为何这么说?
2026-05-14栏目: 教程
-
量子信息和量子技术白皮书合肥宣言在中科大发布
2026-05-14栏目: 教程
-
微信悄悄更新一新功能,来看看!
2026-05-14栏目: 教程
