HTMLFormControlsCollection.namedItem()

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

var item = collection.namedItem(str);
var item = collection[str];

Parameters

Return value

Example

HTML

<form>
  <input id="my-form-control" type="textarea">
</form>

JavaScript

// Returns the HTMLInputElement representing #my-form-control
elem1 = document.forms[0]['my-form-control'];

Specifications

Specification Status Comment
HTML Living Standard
The definition of 'HTMLFormControlsCollection.namedItem()' in that specification.
Living Standard  
HTML5
The definition of 'HTMLFormControlsCollection' in that specification.
Recommendation In this snapshot of HTML Living Standard, the HTMLFormControlsCollections is defined for the first time.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
Basic supportChrome Full support YesEdge No support NoFirefox Full support 33
Full support 33
No support 27 — 33
Notes
Notes Returned a NodeList instead of a RadioNodeList.
IE No support NoOpera Full support YesSafari ? WebView Android Full support YesChrome Android Full support YesEdge Mobile No support NoFirefox Android Full support 33
Full support 33
No support 27 — 33
Notes
Notes Returned a NodeList instead of a RadioNodeList.
Opera Android Full support YesSafari iOS ? Samsung Internet Android ?

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
See implementation notes.
See implementation notes.

See also

Document Tags and Contributors

Contributors to this page: mfluehr, sideshowbarker, Quanyails, connorshea, rvighne, teoli
Last updated by: mfluehr,