English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
formsA read-only attribute returns the embedded<FORM>List of elements.
The elements in the list are sorted in the order they appear in the source code.
If the document does not have a form, the returned list is empty and the length is zero.
document.forms
var x = document.forms.length;Test and see‹/›
All browsers fully support the forms attribute:
Attribute | |||||
forms | Is | Is | Is | Is | Is |
Attribute | Description |
---|---|
length | Returns the list in<form>Number of elements |
Method | Description |
---|---|
[index] | Returns the specific node at the given index, starting from zero, in the list. If the index number is out of range, it returns null. |
item(index) | Returns the specific node at the given index, starting from zero, in the list. If the index number is out of range, it returns null. |
namedItem(id) | Returns the specific node that matches the ID name specified with name. If the ID does not exist, it returns null. |
Return Value: | List all document formsHTMLCollectionObject. Each item in the collection is an HTMLFormElement, representing a single <form> element. |
---|---|
DOM Version: | DOM Level1 |
Get the ID of the <form> element in the document:
alert(document.forms[0].id);Test and see‹/›
Use id="alphaForm" to get the HTML content of the form element:
var x = document.forms.namedItem(&39;alphaForm').innerHTML;Test and see‹/›