DOM Interfaces
HTMLDataListElement
Represents a list of suggested values available to a compatible input through its list attribute. Suggestions do not generally restrict input to the listed values. Browser presentation and accessibility vary. Example result: 2.
Formal Syntax & Structure
html syntaxhtml
const element = document.getElementById('demo'); // HTMLDataListElementReturn Value
HTMLDataListElement
An existing HTML DOM object associated with the datalist element in this example; this interface is a type, not a function return contract.
Working Example
Example Snippethtml
<datalist id="demo"> <option value="Oslo"> <option value="Baku"> </datalist> <p> Result: <output id="result"></output> </p> <script> const e = document.getElementById('demo'); const result = value => { document.getElementById("result").textContent = String(value); }; result(e.options.length); </script>