HTML DOM Input Text list Property
Last Updated :
27 Jul, 2025
Improve
The input Text list property in HTML DOM is used to return a reference to the datalist element that contains an input text field.
Syntax:
textObject.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 used to return the input text list property.
<!DOCTYPE html>
<html>
<head>
<title> HTML DOM Input Text list Property</title>
</head>
<body style="text-align:center">
<h1 style="color:green">
GeeksforGeeks
</h1>
<h2>DOM Input Text list property</h2>
<label><b>Your Cars Name:</b> </label>
<input type="text" list="cars" id="text_id" value="">
<datalist id="cars">
<option value="BMW" />
<option value="Bentley" />
<option value="Mercedes" />
<option value="Audi" />
<option value="Volkswagen" />
</datalist><br><br>
<button onclick="btnclick()">Click Here!</button>
<p id="paraID" style="font-size:20px"></p>
<!-- script to access text field -->
<script>
function btnclick() {
var txt = document.getElementById("text_id").list.id;
document.getElementById("paraID").innerHTML = txt;
}
</script>
</body>
</html>
Output:

Supported Browsers:
- Google Chrome 1
- Edge 12
- Mozilla Firefox 1
- Opera
- Safari 1