Set a time for a time field:
document.getElementById("myTime").value = "22:53:05";
Click the button to set a time for the time field.
<!DOCTYPE html> <html> <body> Time: <input type="time" id="myTime"> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from w w w. jav a 2 s . c o m document.getElementById("myTime").value = "22:53:05"; } </script> </body> </html>
The value
property sets or gets the value attribute of a time field.
The value attribute specifies a time for the time field.
Value | Description |
---|---|
hh:mm:ss.ms | Specifies a time for the time field. hh - hour (e.g. 22 for 10.00pm) mm - minutes (e.g. 30) ss - seconds (e.g. 03) ms - milliseconds (e.g 20) Examples: "09:55:32.55", "22:15:35" or "16:00". |
The value
property return a String representing the time (with no timezone information) of the time field.