--- title: HTMLSelectElement.item() slug: Web/API/HTMLSelectElement/item tags: - API - HTML DOM - HTMLSelectElement - Method - Reference translation_of: Web/API/HTMLSelectElement/item ---
HTMLSelectElement.item() メソッドは、選択肢のリスト内で引数で渡された位置にある {{domxref("HTMLOptionElement")}} に対応する {{domxref("Element")}} を返します。存在しない場合は null を返します。
JavaScript では、ブラケット構文に unsigned long の値を入れた selectElt[index] の形が、 selectElt.namedItem(index) と同等です。
var item = collection.item(index); var item = collection[index];
index は unsigned long の値です。item は {{domxref("HTMLOptionElement")}} です。<form>
<select id="myFormControl">
<option id="o1">Opt 1</option>
<option id="o2">Opt 2</option>
</select>
</form>
// Returns the HTMLOptionElement representing #o2 elem1 = document.forms[0]['myFormControl'][1];
| 仕様書 | 状態 | 備考 |
|---|---|---|
| {{SpecName('HTML WHATWG', "#dom-select-item", "HTMLSelectElement.item()")}} | {{Spec2('HTML WHATWG')}} | 最新のスナップショット、 {{SpecName('HTML5 W3C')}} から変更なし。 |
| {{SpecName('HTML5 W3C', "forms.html#dom-select-item", "HTMLSelectElement.item()")}} | {{Spec2('HTML5 W3C')}} | 初回定義、 {{SpecName('HTML WHATWG')}} のスナップショット。 |
The compatibility table in 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.
{{Compat("api.HTMLSelectElement.item")}}