且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Javascript-HTML - 如何迭代页面上的所有表单?

更新时间:2023-12-03 09:55:16

下面的代码将通过一个html文档,获取所有表单,并进行弹出警报,形成。

The code below will go through an html document, get all forms and do a pop-up alert of the names of each form.

var formsCollection = document.getElementsByTagName("form");
for(var i=0;i<formsCollection.length;i++)
{
   alert(formsCollection[i].name);
}

这只是一个开始,看看你是否得到需要的回报。此后,删除警报并继续执行所需的操作。

This is just a start to see if you are getting the reult you require. Thereafter, remove the alert and continue to do what you need to.