Skip to content
Related Articles

Related Articles

HTML DOM Input week list Property

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

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

Syntax:

weekObject.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 week list property.  

HTML




<!DOCTYPE html>
<html>
 
<head>
    <title> HTML DOM Input Week list Property</title>
</head>
 
<body style="text-align:center;">
    <h1 style="color:green;">
        GeeksforGeeks
    </h1>
 
    <h2>DOM Input Week list property</h2>
 
    <form id="formID">
        <input type="week" id="week_id"
            list="week_list" name="geeks"
            value="2019-W10">
        <datalist id="week_list">
            <option value="2021-W12" />
            <option value="2022-w23" />
            <option value="1999-W14" />
            <option value="2022-w15" />
            <option value="1998-W19" />
        </datalist><br><br>
    </form>
    <br>
 
    <button onclick="btnclick()">
        Click Here!
    </button>
 
    <p id="paraID" style="font-size:20px;"></p>
 
 
 
 
    <!-- Script returns the Input week list property  -->
    <script>
        function btnclick() {
            var weeklistVar = document
                .getElementById("week_id").list.id;
 
            document.getElementById("paraID")
                .innerHTML = weeklistVar;
        }
    </script>
</body>
 
</html>


Output:

 

Supported Browsers:

  • Google Chrome 20
  • Edge 12
  • Opera 11

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!