Open In App

HTML DOM Input Datetime list Property

Last Updated : 14 May, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

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

Syntax:

datetimeObject.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 datetime list property.  

HTML




<!DOCTYPE html>
<html>
  
<head>
    <title>Input Datetime list Property in HTML</title>
  
    <style>
        h1 {
            color: green;
        }
  
        body {
            text-align: center;
        }
    </style>
</head>
  
<body>
    <h1>GeeksforGeeks</h1>
    <h2>Input Datetime list property</h2>
      
    <br> Date Of Birth:
    <input type="datetime" id="Test_Datetime" 
        value="2019-11-11" list="DateTime_list">
    <datalist id="DateTime_list">
        <option value="2019-11-11" />
        <option value="2019-12-01" />
        <option value="2019-04-11" />
        <option value="2005-09-12" />
        <option value="2022-03-12" />
    </datalist><br><br>
  
    <button ondblclick="My_Datetime()">
        Return Date And Time
    </button>
  
    <p id="test" style="font-size:20px"></p>
  
  
    <script>
        function My_Datetime() {
            var datetimeVar = document
                .getElementById("Test_Datetime").list.id;
                  
            document.getElementById("test")
                .innerHTML = datetimeVar;
        }
    </script>
</body>
  
</html>


Output: 

 

Supported Browsers:

  • Google Chrome
  • Edge
  • Mozilla Firefox
  • Opera
  • Safari


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads