HTMLSelectElement: form プロパティ

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

HTMLSelectElement.form は読み取り専用のプロパティで、この要素が関連付けられているフォームを表す HTMLFormElement を返します。この要素が <form> 要素に関連付けられていなかった場合は、null を返します。

HTMLFormElement です。

html
<form id="pet-form">
  <label for="pet-select">ペットを選択してください</label>
  <select name="pets" id="pet-select">
    <option value="dog"></option>
    <option value="cat"></option>
    <option value="parrot">オウム</option>
  </select>

  <button type="submit">送信</button>
</form>

<label for="lunch-select">ランチを選んでください</label>
<select name="lunch" id="lunch-select">
  <option value="salad">サラダ</option>
  <option value="sandwich">サンドウィッチ</option>
</select>

<script>
  const petSelect = document.getElementById("pet-select");
  const petForm = petSelect.form; // <form id="pet-form">

  const lunchSelect = document.getElementById("lunch-select");
  const lunchForm = lunchSelect.form; // null
</script>

仕様書

Specification
HTML
# dom-fae-form-dev

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
form

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support