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

浏览器兼容性

另见