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
str
is aDOMString
Return value
item
is aRadioNodeList
,Element
, ornull
.
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 StandardThe definition of 'HTMLFormControlsCollection.namedItem()' in that specification. | Living Standard | |
HTML5The definition of 'HTMLFormControlsCollection' in that specification. | Recommendation | In this snapshot of HTML Living Standard, the HTMLFormControlsCollections is defined for the first time.
|
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
namedItem
|
Chrome
Full support Yes |
Edge
Full support 79 |
Firefox Full support 33 |
IE
No support No |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android Full support 33 |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
Legend
- Full support
- Full support
- No support
- No support
- See implementation notes.'
- See implementation notes.
See also
HTMLCollection.namedItem
that it replaces
HTMLFormControlsCollection.namedItem() by Mozilla Contributors is licensed under CC-BY-SA 2.5.