Javascript DOM HTML Input DatetimeLocal Object create

Create an Input DatetimeLocal Object

We can create an <input> element with type="datetime-local" via the document.createElement() method:

Click the button to create a Local Datetime field.

View in separate window

<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">Test</button>

<script>
function myFunction() {//w ww .j  a va2  s . co  m
  var x = document.createElement("INPUT");
  x.setAttribute("type", "datetime-local");
  document.body.appendChild(x);
}
</script>

</body>
</html>



PreviousNext

Related