Setting the month of input
You can use the value attribute like any other type
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/month
If you are looking for a JS solution, just as you set the value for input, you can do
document.getElementById("abc").value = "2017-09";
Notes:
1) When using it, there should always be a year. This is a big nasty thing.
2) Keep in mind that there are problems with the browser with it.
However, there are problems, because at this time many major browsers do not yet support it.
, " " ).
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/month#Handling_browser_support
:
, ,
- ( - ) , ( , . ) JavaScript, jQuery.
, ,
const monthControl = document.querySelector('#month-control[type="month"]');
monthControl.value = '1978-06';
<input type="month" id="month-control">
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari
Basic support | 20 | 12 | No support[1] | No support | 10.62 | No support[2]
var month = document.getElementsByClassName('month');
for (i = 0; i < month.length; i++) {
month[i].value = '2017-06';
}
<input type="text" class="month" >
<input type="text" class="month" >