Javascript Reference - HTML DOM Input Datetime type Property








The type property returns the type of the datetime field.

Browser Support

type No No No No No

Syntax

var v = datetimeObject.type

Return Value

A String type value representing the type of the datetime field.





Example

The following code shows how to get the type of the datetime field.


<!DOCTYPE html>
<html>
<body>
A datetime field: <input type="datetime" id="myDatetime">
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<!--from w  w w.  j  av a 2  s.  c  om-->
<script>
function myFunction() {
    var x = document.getElementById("myDatetime").type;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The code above is rendered as follows: