--- title: HTMLSelectElement.selectedOptions slug: Web/API/HTMLSelectElement/selectedOptions tags: - API - HTML DOM - HTMLSelectElement - Options - プロパティ - 読み取り専用 - リファレンス - Select - ウェブ - selectedOptions browser-compat: api.HTMLSelectElement.selectedOptions --- {{APIRef("HTML DOM")}} **読み取り専用**の {{domxref("HTMLSelectElement")}} の **`selectedOptions`** プロパティは、この {{HTMLElement("select")}} 要素にある現在選択中の {{HTMLElement("option")}} のリストが入ります。選択中の選択肢のリストは {{domxref("HTMLCollection")}} オブジェクトで、現在選択中の選択肢ごとに 1 項目ずつ入ります。 選択肢は {{domxref("HTMLOptionElement.selected")}} 属性を持つ場合に選択されたとみなされます。 ## 構文 ```js var selectedCollection = HTMLSelectElement.selectedOptions; ``` ### 値 {{domxref("HTMLCollection")}} で、{{domxref("HTMLSelectElement")}} または `` 要素に含まれる選択肢はすべて結果に含まれますが、選択肢グループはリストに含まれません。 現在選択中の選択肢がない場合は、コレクションは空になり、{{domxref("HTMLCollection.length", "length")}} は 0 になります。

この例では、いくつかの選択肢を持つ {{HTMLElement("select")}} 要素を使用し、ユーザーがさまざまな食べ物を注文できるようにしています。 ### HTML 選択ボックスと、それぞれの食べ物の選択肢を表す {{HTMLElement("option")}} 要素を生成する HTML は次のようになります。 ```html

``` `