W3cubDocs

/DOM

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

Examples

<form>
  <input id="myFormControl" type="textarea"/>
</form>
elem1 = document.forms[0]["myFormControl"]; // Returns the HTMLInputElement representing #myFormControl

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 compatibilityUpdate compatibility data on GitHub

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
Basic support Yes No 33
33
27 — 33
Returned a NodeList instead of a RadioNodeList.
No Yes ?
Mobile
Android webview Chrome for Android Edge Mobile Firefox for Android Opera for Android iOS Safari Samsung Internet
Basic support Yes Yes No 33
33
27 — 33
Returned a NodeList instead of a RadioNodeList.
Yes ? ?

See also

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormControlsCollection/namedItem