Home > Web Front-end > JS Tutorial > JavaScript method to get the number of forms in the page_javascript skills

JavaScript method to get the number of forms in the page_javascript skills

WBOY
Release: 2016-05-16 16:05:43
Original
1089 people have browsed it

The example in this article describes the method of using JavaScript to obtain the number of forms on the page. Share it with everyone for your reference. The details are as follows:

The following JS code obtains the number of forms in the web page through the document.forms array

<!DOCTYPE html>
<html>
<body>
<h1>sharejs.com</h1>
<form name="Form1"></form>
<form name="Form2"></form>
<form></form>
<p>Number of forms:
<script>
document.write(document.forms.length);
</script></p>
</body>
</html>
Copy after login

The running results are as follows:

Number of forms: 3
Copy after login

I hope this article will be helpful to everyone’s JavaScript programming design.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template