Input Time step Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Time

Description

The step property sets or gets the step of a time field, which identifies the legal number intervals for seconds or milliseconds in a time field.

For example: if step="2", legal numbers could be 0, 2, 4, etc.

Set the step property with the following Values

Value Description
number Sets the legal number intervals in the time field.
  • For seconds: Use numbers that will eventually reach "60". Like: "1, "2", "10", "30", etc.
  • For milliseconds: Start with "." and use numbers that eventually will reach "1000". Like ".010", ".050", ".20", etc.

Return Value

A Number, representing the legal number intervals for seconds or milliseconds

The following code shows how to change the legal number intervals for seconds in a time field:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>
Time: <input type="time" id="myTime" value="16:32:55">

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

<script>
function myFunction() {//  w  w w.j a  v  a2 s .  c o m
    document.getElementById("myTime").stepUp();
}
</script>

</body>
</html>

Related Tutorials