HTML-DOM bildet Sammlung
Definition und Verwendung
Liefert die aktuelle Seite Sammlung bildet ein Array aller Formen der Sammlung.
Grammatik
document.forms[].property
Browser-Unterstützung
Alle gängigen Browser unterstützen Formen Sammlung
Beispiele
Beispiel 1
Gibt die Anzahl der Formulare im Dokument:
<html>
<body>
<form name="Form1"></form>
<form name="Form2"></form>
<form></form>
<p>表单数目:
<script>
document.write(document.forms.length);
</script></p>
</body>
</html>
<body>
<form name="Form1"></form>
<form name="Form2"></form>
<form></form>
<p>表单数目:
<script>
document.write(document.forms.length);
</script></p>
</body>
</html>
Beispiele für die obigen Ausgangs:
表单数目: 3
Versuchen »
Beispiel 2
Gibt den Namen des ersten Dokuments in Form von:
<html>
<body>
<form name="Form1"></form>
<form name="Form2"></form>
<form></form>
<p>第一个表单名称:
<script>
document.write(document.forms[0].name);
</script></p>
</body>
</html>
<body>
<form name="Form1"></form>
<form name="Form2"></form>
<form></form>
<p>第一个表单名称:
<script>
document.write(document.forms[0].name);
</script></p>
</body>
</html>
Beispiele für die obigen Ausgangs:
第一个表单名称: Form1
Versuchen »
Document Object