A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.cdn.mozilla.net/ja/docs/Web/API/HTMLSelectElement/value below:

HTMLSelectElement: value プãƒãƒ‘ティ - Web API

HTMLSelectElement: value プロパティ

Baseline Widely available

HTMLSelectElement.value プロパティは、この <select> 要素に関連付けられた <option> 要素のうち、選択された最初のものの値を格納します。

このプロパティは直接設定することもでき、例えば、何らかの条件に基づいて既定値を設定するには、次のようにします。

値

この <select> 要素で最初に選択された <option> 要素の値を格納する文字列、またはオプションが選択されていない場合は空文字列。

例 選択された値の取得
<label for="bird-select">鳥を選択してください:</label>

<select name="birds" id="bird-select">
  <option value="">--オプションを選択してください--</option>
  <option value="Scarlet ibis">ショウジョウトキ</option>
  <option value="Marabou stork">マラボウコウノトリ</option>
  <option value="Roseate spoonbill">ベニヘラサギ</option>
</select>

<pre id="log"></pre>
const logElement = document.querySelector("#log");
function log(text) {
  logElement.innerText = text;
}

const select = document.querySelector("#bird-select");
select.addEventListener("change", () => {
  log(`選択: ${select.value}`);
});
#log {
  height: 20px;
  padding: 0.5rem;
  border: 1px solid black;
}
仕様書 ブラウザーの互換性 関連情報

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4