Open In App

HTML DOM Input DatetimeLocal list Property

Last Updated : 29 Jan, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

The input DateTimeLocal list property in HTML DOM returns a reference to the list element that contains an input datetimelocal field.

Syntax:

DatetimelocalObject.list.id

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

Example: This HTML code returns the input DateTimeLocal list Property. 

HTML
<!DOCTYPE html>
<html>

<head>
    <title>
        HTML DOM Input DatetimeLocal list Property
    </title>
</head>

<body style="text-align: center;">
    <h1>GeeksforGeeks</h1>

    <h2>HTML DOM Input DatetimeLocal list Property</h2>
    
    <br> Date Of Birth:
    <input type="datetime-local" 
        list="DateTimeLocal_list" 
        id="Test_DatetimeLocal">

    <datalist id="DateTimeLocal_list">
        <option value="2019-02-04T12:32:20.51">
        <option value="2019-02-04T12:32:20.51">
        <option value="2019-02-04T12:32:20.51">
        <option value="2019-02-04T12:32:20.51">
    </datalist><br><br>

    <button onclick="My_DatetimeLocal()">
        Click Here!
    </button>
    
    <p id="result"></p>

    <script>
        function My_DatetimeLocal() {
            let x = document.getElementById(
                "Test_DatetimeLocal").list.id;

            document.getElementById("result").innerHTML = x;
        }
    </script>
</body>

</html>

Output:

datetimeLocal-list

Supported Browsers:

  • Google Chrome 20
  • Edge 12
  • Firefox 93
  • Opera 11
  • Safari 14.1

Next Article

Similar Reads