Javascript DOM HTML Input Time defaultValue Property get

Introduction

Get the default value of a time field:

var x = document.getElementById("myTime").defaultValue;

Click the button to display the default value of the time field.

View in separate window

<!DOCTYPE html>
<html>
<body>

Time: <input type="time" id="myTime" value="21:43:54">
<button type="button" onclick="myFunction()">Test</button>

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

<script>
function myFunction() {/*from w  w  w  . j a va 2s .c o m*/
  var x = document.getElementById("myTime").defaultValue;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>



PreviousNext

Related