Name
Form.elements[]: the input elements of a form â DOM Level 2 HTML
Synopsis
readonly HTMLCollection elements
Description
elements[]
is an array-like
HTMLCollection of the form elements (such as Input, Select, and
Textarea objects) that appear in an HTML form. The elements of the
array are in the same order they appear in the HTML source code for
the form. Each element has a type
property whose string value identifies its type.
Usage
If an item in the elements[]
array has been given a name
with the name="
name
"
attribute of its HTML <input>
tag, that itemâs name
becomes a property of form
, and this
property refers to the item. Thus, it is possible to refer to input
elements by name instead of by number:
form.name
See Also
Input
, HTMLCollection
, Select
, Textarea
Get JavaScript: The Definitive Guide, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.