Javascript-HTML - how to iterate through all the forms on a page?

前端 未结 3 741
暗喜
暗喜 2021-02-15 03:56

How can I iterate through all forms in a document using javascript?

3条回答
  •  既然无缘
    2021-02-15 04:38

    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

    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.

提交回复
热议问题