The value
property sets or gets the value attribute of a time field.
The value
attribute specifies a time for the time field.
value |
Yes | No | No | Yes | Yes |
Return the value property.
var v = timeObject.value
Set the value property.
timeObject.value=hh:mm:ss.ms
Value | Description |
---|---|
hh:mm:ss.ms | Specifies a time for the time field.
|
A String type value representing the time of the time field.
The following code shows how to get the time of a time field.
<!DOCTYPE html>
<html>
<body>
<!--from w w w . j a v a 2s .c om-->
Time: <input type="time" id="myTime" value="21:32:55">
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myTime").value;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows:
The following code shows how to set a time for a time field.
<!DOCTYPE html>
<html>
<body>
Time: <input type="time" id="myTime">
<button onclick="myFunction()">test</button>
<!-- w w w . j a va 2 s .c om-->
<p id="demo"></p>
<script>
function myFunction() {
document.getElementById("myTime").value = "22:53:05";
}
</script>
</body>
</html>
The code above is rendered as follows: