Skip to content
Related Articles

Related Articles

HTML DOM Input Month list Property

Improve Article
Save Article
  • Last Updated : 29 Aug, 2022
Improve Article
Save Article

The input month list property in HTML DOM is used to return a reference to the datalist element that contains an input month field.

Syntax:

monthObject.list.id

Return Value: It returns a string value that represents the value of the id attribute of the datalist element.

Example: Below HTML code is used to return the input month list property.

HTML




<!DOCTYPE html>
<html>
<head>
    <title>HTML DOM Input Month list property</title>
</head>
<body style="text-align:center;">
    <h1 style="color:green;">
        GeeksforGeeks
    </h1>
    <h2>DOM Input Month list property</h2>
    <form id="formID">
       <input type="month" id="month_id" list = "month_list"
             name="geeks" value="2019-03">
         <datalist id="month_list">
            <option value="15" />
            <option value="20" />
            <option value="40" />
            <option value="30" />
            <option value="35" />
        </datalist><br><br>
    </form>
    <button onclick="btnclick()">Click Here!</button>
    <p id="paraID" style="font-size:20px;"></p>
 
    
    <!-- Script to return the Input Month list property-->
    <script>
        function btnclick() {
            var gfg = document.getElementById("month_id").list.id;
            document.getElementById("paraID").innerHTML = gfg;
        }
    </script>
</body>
</html>


Output:

 

Supported Browsers: 

  • Google Chrome 20 and above
  • Edge 12 and above
  • Opera 11 and above

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!