แอตทริบิวต์ step ใน HTML ใช้กำหนดช่วงตัวเลขสำหรับองค์ประกอบ <input> ในเอกสาร HTML
ไวยากรณ์
<input step="number">
ตัวอย่าง
<!DOCTYPE html>
<html>
<style>
body {
color: #000;
height: 100vh;
background-color: #8BC6EC;
background-image: linear-gradient(135deg, #8BC6EC 0%, #9599E2 100%);
text-align: center;
}
</style>
<body>
<h1>ตัวอย่าง HTML step</h1>
<p>ป้อนจำนวนออเดอร์:</p>
<input type="number" step="5" value="0">
</body>
</html>
ผลลัพธ์
แสดงช่องป้อนตัวเลขที่เพิ่ม/ลดทีละ 5 เมื่อกดปุ่มลูกศรขึ้น/ลง
ลองป้อนตัวเลขแล้วกดลูกศรขึ้น/ลงเพื่อดูการทำงาน