HTMLFormControlsCollection.namedItem() - Web APIs 编辑
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 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
BCD tables only load in the browser
See also
HTMLCollection.namedItem
that it replaces
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论