Javascript examples for DOM HTML Element:Input Month
The value property sets or gets the value attribute of a month field.
The value attribute sets a month and year for the month field.
Set the value property with the following Values
Value | Description |
---|---|
YYYY-MM | Sets the month and year. |
A String, representing the month and year of the month field
The following code shows how to Set the month and year for a month field:
<!DOCTYPE html> <html> <body> Month and year: <input type="month" id="myMonth" value="1997-11"> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*from w w w . j av a 2 s . co m*/ document.getElementById("myMonth").value = '2997-11'; document.getElementById("demo").innerHTML = 'set'; } </script> </body> </html>