HTMLFormControlsCollection: namedItem() method
The HTMLFormControlsCollection.namedItem() method returns
the RadioNodeList or the Element in the collection whose
name or id match the specified name, or null if
no node matches.
Note that this version of namedItem() hides the one inherited from
HTMLCollection. Like that one, in JavaScript, using the array bracket
syntax with a String, like collection["value"] is
equivalent to collection.namedItem("value").
Syntax
js
namedItem(str)
// or collection[str]
Parameters
stris a string
Return value
-
itemis aRadioNodeList,Element, ornull.
Examples
HTML
html
<form>
<input id="my-form-control" type="textarea" />
</form>
JavaScript
js
// Returns the HTMLInputElement representing #my-form-control
elem1 = document.forms[0]["my-form-control"];
Specifications
| Specification |
|---|
| HTML Standard # dom-htmlformcontrolscollection-nameditem-dev |
Browser compatibility
BCD tables only load in the browser
See also
HTMLCollection.namedItemthat it replaces