diff options
author | Masahiro FUJIMOTO <mfujimot@gmail.com> | 2021-10-28 02:00:01 +0900 |
---|---|---|
committer | Masahiro FUJIMOTO <mfujimot@gmail.com> | 2021-11-04 21:36:13 +0900 |
commit | ed4edb19c89e81e9f6e68f6820b166d106519be6 (patch) | |
tree | aaa2ad0f16fad2a547ec5011d5c3e40180555b96 /files/ja/web/api/htmlselectelement/disabled | |
parent | 485a48198a98d7213af29b946d473c9c3329a6b1 (diff) | |
download | translated-content-ed4edb19c89e81e9f6e68f6820b166d106519be6.tar.gz translated-content-ed4edb19c89e81e9f6e68f6820b166d106519be6.tar.bz2 translated-content-ed4edb19c89e81e9f6e68f6820b166d106519be6.zip |
Web/API/HTMLSelectElement 以下の文書を更新
- 2021/10/27 時点の英語版に同期
- add, checkValidity, disabled, form, labels, namedItem, remove, selectedIndex, selectedOptions, setCustomValidaty, type については新規翻訳
Diffstat (limited to 'files/ja/web/api/htmlselectelement/disabled')
-rw-r--r-- | files/ja/web/api/htmlselectelement/disabled/index.md | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/files/ja/web/api/htmlselectelement/disabled/index.md b/files/ja/web/api/htmlselectelement/disabled/index.md new file mode 100644 index 0000000000..6c0b222256 --- /dev/null +++ b/files/ja/web/api/htmlselectelement/disabled/index.md @@ -0,0 +1,66 @@ +--- +title: HTMLSelectElement.disabled +slug: Web/API/HTMLSelectElement/disabled +tags: + - API + - HTML DOM + - HTMLSelectElement + - プロパティ +browser-compat: api.HTMLSelectElement.disabled +translation_of: Web/API/HTMLSelectElement/disabled +--- +{{ APIRef("HTML DOM") }} + +**`HTMLSelectElement.disabled`** は論理値で、HTML の [`disabled`](/ja/docs/Web/HTML/Element/select#attr-disabled) 属性を反映し、このコントロールが無効であるかどうかを示します。無効であった場合、クリックを受け付けません。無効な要素は使用できず、クリックできません。 + +## 構文 + +```js +aSelectElement.disabled = aBool; +``` + +<h2 id="Example">例</h2> + +### HTML + +```html +<label> + 飲み物はいかが? + <input id="allow-drinks" type="checkbox"/> +</label> + +<label for="drink-select">飲み物の選択:</label> +<select id="drink-select" disabled> + <option value="1">水</option> + <option value="2">ビール</option> + <option value="3">ペプシ</option> + <option value="4">ウィスキー</option> +</select> +``` + +### JavaScript + +```js +var allowDrinksCheckbox = document.getElementById("allow-drinks"); +var drinkSelect = document.getElementById("drink-select"); + +allowDrinksCheckbox.addEventListener("change", function(event) { + if (event.target.checked) { + drinkSelect.disabled = false; + } else { + drinkSelect.disabled = true; + } +}, false); +``` + +### 結果 + +{{EmbedLiveSample('Example')}} + +## 仕様書 + +{{Specifications}} + +## ブラウザーの互換性 + +{{Compat}} |