Input Time defaultValue Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Time


The defaultValue property sets or gets the default value of a time field.

The default value is the value specified in the HTML value attribute.

You can use defaultValue property to find out whether the time of a time field have been changed.

Set the defaultValue property with the following Values

Value Description
value Sets the default value of the search field

Return Value

A String, representing the default value of the search field

The following code shows how to change the default value of a time field:

Demo Code

ResultView the demo in separate window

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

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

<p id="demo"></p>

function myFunction() {/*w w w . j a v  a2 s  . co  m*/
    var x = document.getElementById("myTime");
    x.defaultValue = '22:22:22';



Related Tutorials