Open In App

HTML DOM Input Number list Property

Last Updated : 29 Apr, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

The input number list property in HTML DOM returns a reference to the datalist element that contain 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: This code returns the input number list property. 

HTML
<!DOCTYPE html>
<html>

<body>
    <h1>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="GFG"></p>

    <script>
        function myFunction() {

            // Returning Input Number list Property
            let x = document.getElementById("myNumber").list.id;
            document.getElementById("GFG").innerHTML = x;
        }
    </script>
</body>

</html>

Output

DOM-Input-Number-list-property

Supported Browsers

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

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads