HTMLInputElement: step 屬性

Baseline 已廣泛支援

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

HTMLInputElement 介面的 step 屬性指示數字或日期時間 <input> 元素可以更改的步長。它反映了元素的 step 屬性。有效值包括字串 "any" 或包含正浮點數的字串。如果未顯式設定屬性,則 step 屬性為空字串。

一個表示元素 step 值或在未顯式設定任何步長時的空字串。

示例

js
const inputElement = document.querySelector('[type="number"]');
console.log(inputElement.step); // the current value of the step attribute
inputElement.step = 0.1; // sets the step value to "0.1"
inputElement.step = "any"; // sets the step to "any"

規範

規範
HTML
# dom-input-step

瀏覽器相容性

另見