HTML step 屬性
定義和用法
step
屬性指定 <input> 元素的合法數字間隔。
例如:如果 step="3"
,則合法的數字可以是 -3、0、3、6 等。
提示: step
屬性可以與 max
和 min
屬性結合使用,以建立合法的數值範圍。
注意: step
屬性適用於以下輸入型別:number、range、date、datetime、datetime-local、month、time 和 week。
適用範圍
step
屬性可用於以下元素
元素 | Attribute |
---|---|
<input> | step |
示例
具有指定合法數字間隔的輸入欄位的 HTML 表單
<form action="/action_page.php">
<input type="number" name="points" step="3">
<input type="submit">
</form>
自己動手試一試 »
瀏覽器支援
表格中的數字表示完全支援該屬性的第一個瀏覽器版本。
Attribute | |||||
---|---|---|---|---|---|
step | 6.0 | 10.0 | 16.0 | 5.0 | 10.6 |