このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

View in English Always switch to English

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 ⁨2015年7月⁩.

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

ブラウザーの互換性