HTMLSelectElement.options

HTMLSelectElement.options は読み取り専用のプロパティで、HTMLOptionsCollection<select> 要素に含まれる <option> 要素を返します。

構文

var options = select.options;

返値

HTMLOptionsCollection で、<select> 要素に含まれる <option> 要素を返します。

HTML

<label for="test">ラベル</label>
<select id="test">
  <option value="1">Option 1</option>
  <option value="2">Option 2</option>
</select>

JavaScript

window.addEventListener("DOMContentLoaded", function() {
  const select = document.getElementById("test");
  for(var i = 0; i < select.options.length; i++) {
    console.log(select.options[i].label); // "Option 1" および "Option 2"
  }
});

仕様書

Specification
HTML Standard
# dom-select-options-dev

ブラウザーの互換性

BCD tables only load in the browser