HTMLFormControlsCollection.namedItem()
TheHTMLFormControlsCollection.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()
hide 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
JavaScript
Copy Code
var item = collection.namedItem[str]; var item = collection[str];
Parameters
- str is a
DOMString
Return value
- item is a
RadioNodeList
or anElement
.
Examples
HTML
Copy Code
<form> <input id="myFormControl" type="textarea"/> </form>
CSS
Copy Code
elem1 = document.forms[0]["myFormControl"]; // Returns the HTMLInputElement representing #myFormControl
Specifications
Specification | Status | Comment |
---|---|---|
WHATWG HTML Living Standard The definition of 'HTMLFormControlsCollection' in that specification. |
Living Standard | No change since the last snapshot, HTML5. |
HTML5 The definition of 'HTMLFormControlsCollection' in that specification. |
Recommendation | In this snapshot of WHATWG HTML Living Standard, the HTMLFormControlsCollections is defined for the first time. |
Browser compatibility
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | (Yes) | 27 (27) [1] | Not supported | (Yes) | ? |
Feature | Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | (Yes) | 27.0 (27) [1] | Not supported | (Yes) | ? |
[1] Until Firefox 32 included, the eventual RadioNodeList
returned by namedItem
was a NodeList
.
See also
HTMLCollection.namedItem
that it replaces.
License
© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-us/docs/web/api/htmlformcontrolscollection/nameditem