This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2019.
The list read-only property of the HTMLInputElement interface returns the HTMLDataListElement pointed to by the list attribute of the element, or null if the list attribute is not defined or the list attribute's value is not associated with any <datalist> in the same tree.
Note: This is a read-only property. To associate a <datalist> with an element, set the value of the list attribute with setAttribute().
An HTMLDataListElement or null.
Given the following HTML:
<label for="planet">Which planet are you from?</label> <input id="planet" type="text" list="superhero" /> <datalist id="superhero"> <option value="Azarath"></option> <option value="Krypton"></option> <option value="Tamaran"></option> </datalist>
You can retrieve the <datalist> element associated with the <input>:
const inputElement = document.querySelector("#planet");
console.log(inputElement.list); // returns the superhero HTMLDatalistElement
| Specification |
|---|
| HTML> # dom-input-list-dev> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
list |
20 | 12 | 4 | ≤12.1 | 12.1 | 25 | 4 | ≤12.1 | 12.2 | 1.5 | 4.4.3 | 12.2 |
HTMLInputElement.valueHTMLInputElement.typeHTMLDataListElementHTMLOptionElementHTMLCollection<input><datalist><option>
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/list