Javascript DOM HTML Input Month type Property get

Introduction

Return the type of form element for the month field:

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

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

The type property is not supported by Firefox.

View in separate window

<!DOCTYPE html>
<html>
<body>

<input type="month" id="myMonth">
<button onclick="myFunction()">Test</button>
<p id="demo"></p>

<script>
function myFunction() {/*from  w ww . java2s. com*/
  var x = document.getElementById("myMonth").type;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The type property returns which type of form element the month field is.

For month field the browser returns "month".




PreviousNext

Related