Skip to content
Related Articles

Related Articles

HTML DOM Input Number list Property

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

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

Syntax:

numberObject.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 number list property. 

HTML




<!DOCTYPE html>
<html>
<body style="text-align:center;">
    <h1 style="color:green;">
        GeeksforGeeks
    </h1>
    <h2>DOM Input Number list property</h2>
    <legend>Multiples of 5:
        <input type="number" id="myNumber"
            list="numbers" value="10">
    </legend>
    <datalist id="numbers">
        <option value="15" />
        <option value="20" />
        <option value="40" />
        <option value="30" />
        <option value="35" />
    </datalist><br><br>
    <button onclick="myFunction()">
        Click Here!
    </button>
    <p id="demo"></p>
 
    <script>
        function myFunction() {
     
            // Returning Input Number list Property
            var x = document.getElementById("myNumber").list.id;
            document.getElementById("demo").innerHTML = x;
        }
    </script>
</body>
</html>


Output: 

 

Supported Browsers:

  • Google Chrome
  • Edge 12 and above
  • Mozilla Firefox
  • Opera
  • Safari

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!