Get Input Month Field - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Month


The Input Month object represents an HTML <input> element with type="month".

You can access an <input> element with type="month" by using getElementById():

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<input type="month" id="myMonth" value="2014-05">

<button onclick="myFunction()">get the month and year of the month field</button>

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

function myFunction() {//  w ww .  jav a 2s. c om
    var x = document.getElementById("myMonth").value;
    document.getElementById("demo").innerHTML = x;


Related Tutorials