Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. HTMLInputElement
  4. list

HTMLInputElement: list property

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨March 2019⁩.

Thelist read-only property of theHTMLInputElement interface returns theHTMLDataListElement pointed to by thelist attribute of the element, ornull if thelist attribute is not defined or thelist 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 thelist attribute withsetAttribute().

Value

AnHTMLDataListElement ornull.

Example

Given the following HTML:

html
<label for="planet">Which planet are you from?</label><input type="text" list="superhero" /><datalist>  <option value="Azarath"></option>  <option value="Krypton"></option>  <option value="Tamaran"></option></datalist>

You can retrieve the<datalist> element associated with the<input>:

js
const inputElement = document.querySelector("#planet");console.log(inputElement.list); // returns the superhero HTMLDatalistElement

Specifications

Specification
HTML
# dom-input-list-dev

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp