Javascript DOM HTML Input Datetime type Property get

Introduction

Return element type for the datetime field:

var x = document.getElementById("myDatetime").type;

Click the button to return which type of form element the datetime field is.

View in separate window

<!DOCTYPE html>
<html>
<body>

A datetime field: <input type="datetime" id="myDatetime">
<button onclick="myFunction()">Test</button>
<p id="demo"></p>

<script>
function myFunction() {//from www . j ava2  s  . c  om
  var x = document.getElementById("myDatetime").type;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The type property returns the type of form for the datetime field.




PreviousNext

Related