HTMLOptionsCollection

我们的志愿者还没有将这篇文章翻译为 中文 (简体)加入我们帮助完成翻译
您也可以阅读此文章的English (US)版。

HTMLOptionsCollection is an interface representing a collection of HTML option elements (in document order) and offers methods and properties for traversing the list as well as optionally altering its items. This type is returned solely by the "options" property of select.

Properties

Name Type Description
length unsigned long As optionally allowed by the spec, Mozilla allows this property to be set, either removing options at the end when using a shorter length, or adding blank options at the end when setting a longer length. Other implementations could potentially throw a DOMException.

Methods

  • item(index) - returns the specific node at the given zero-based index (gives null if out of range)
  • namedItem(name) - returns the specific node with the given DOMString (i.e., string) id. Returns null if no such named node exists.

Specification

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support Yes Yes Yes Yes Yes Yes
length Yes13 Yes Yes Yes Yes
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support Yes Yes Yes Yes Yes Yes Yes
length Yes Yes Yes Yes Yes Yes Yes

See also

文档标签和贡献者

最后编辑者: ExE-Boss,