The Input type month property autofocus used to set and retrieve whether a month field should automatically get focus when the page loads. It returns boolean value true, if the month input field autofocus on page load, otherwise false.
1 <input>.autofocus
2 <input>.autofocus = <boolean>
input : A input type month element object to set and retrieve autofocus property
boolean : It specifies whether month input field should autofocus on page load
Possible values
Input month property autofocus
1 <!DOCTYPE html>
2 <html>
3 <style>
4 .container {
5 margin: 20px 0;
6 }
7 </style>
8 <body>
9 <h1>The Input Month Object</h1>
10 <h2>Example</h2>
11
12 <div class="container">
13 <input id="month" type="month" autofocus />
14 </div>
15
16 <button onclick="access()">Access</button>
17 <p id="result"></p>
18 <script>
19 function access() {
20 const element = document.getElementById("month");
21 const str = `Is month field autofocus ? <b>${element.autofocus}</b>`;
22 document.getElementById("result").innerHTML = str;
23 }
24 </script>
25 </body>
26 </html>
Input month property autofocus
Related options for your search