HTMLInputElement: indeterminate 屬性

Baseline 已廣泛支援

此特性已相當成熟,可在許多裝置和瀏覽器版本上使用。自 ⁨2015 年 7 月⁩以來,各瀏覽器均已提供此特性。

HTMLInputElement 介面的 indeterminate 屬性返回一個布林值,指示覆選框是否處於不確定狀態。例如,當其子控制元件中的部分(但不是全部)被選中時,“全選/全不選”複選框可能處於不確定狀態。indeterminate 狀態只能透過 JavaScript 設定,並且僅與 checkbox 控制元件相關。

它與 HTMLInputElement.checked 屬性無關,並且不確定的複選框可以被選中或未選中。處於不確定狀態僅影響複選框的外觀(參見下面的示例),而不影響其提交時的存在(這由選中狀態控制)。

布林值。

示例

html
<input type="checkbox" id="indeterminate-checkbox" />
<label for="indeterminate-checkbox">Indeterminate checkbox</label>
js
const checkbox = document.getElementById("indeterminate-checkbox");
checkbox.indeterminate = true;

規範

規範
HTML
# dom-input-indeterminate

瀏覽器相容性

另見