Get the number intervals for a number field:
var x = document.getElementById("myNumber").step;
Click the button to display the value of the step attribute of the number field.
<!DOCTYPE html> <html> <body> Number://from w w w . j a v a2 s . co m <input type="number" id="myNumber" step="3"> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("myNumber").step; document.getElementById("demo").innerHTML = x; } </script> </body> </html>
The step
property sets or gets the value of the step attribute of a number field.
The step attribute specifies the number intervals for a number field.
Example: if step="3", legal numbers could be -3, 0, 3, 6, etc.
Value | Description |
---|---|
number | Specifies the legal number intervals for the number field. Default is 1 |
Return Value: | A String, representing the number intervals for the number field |
---|