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