Input Number step Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Number

Description

The step property sets or gets the step attribute of a number field, which controls sets the legal number intervals for a number field.

Example: if step="3", legal numbers could be -3, 0, 3, 6, etc.

Set the step property with the following Values

Value Description
number Sets the legal number intervals for the number field. Default is 1

Return Value

A String, representing the legal number intervals for the number field

The following code shows how to get the legal number intervals for a number field:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>
Number: <input type="number" id="myNumber">

<button onclick="myFunction()">Test</button>

<script>
function myFunction() {/*w  w w .ja  va2 s .  c om*/
    document.getElementById("myNumber").stepUp();
}
</script>

</body>
</html>

Related Tutorials