HTML DOM Formularz właściwość length
Definicja i Wykorzystanie
Właściwość length zwraca liczbę elementów w formie.
gramatyka
formObject.length
Pomoc Browser
Wszystkie główne przeglądarki obsługują właściwości length
Przykłady
Przykłady
Poniższy przykład zwraca liczbę elementów w formie:
<html>
<body>
<form id="frm1" action="form_action.html">
First name: <input type="text" name="fname" value="Donald"><br>
Last name: <input type="text" name="lname" value="Duck"><br>
<input type="submit" value="Submit">
</form>
<script>
document.write(document.getElementById("frm1").length);
</script>
</body>
</html>
<body>
<form id="frm1" action="form_action.html">
First name: <input type="text" name="fname" value="Donald"><br>
Last name: <input type="text" name="lname" value="Duck"><br>
<input type="submit" value="Submit">
</form>
<script>
document.write(document.getElementById("frm1").length);
</script>
</body>
</html>
Przykłady wyżej wyjścia:
3
Spróbuj »
Więcej przykładów
Wartość w postaci każdego elementu
forma obiektu