Skip to content
Related Articles

Related Articles

HTML DOM Input Month list Property

View Discussion
Improve Article
Save Article
  • Last Updated : 01 Aug, 2022

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
  • Internet Explorer 
  • Opera mini 
  • Apple Safari 
  • Firefox

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!