Baseline Widely available
The text
property of the HTMLOptionElement
represents the text inside the <option>
element. This property represents the same information as Node.textContent
.
Note: If the element has a label
, the text inside the <option>
is not visually rendered. In this case, the text
property can still be used to set the content, but it will have no visible effect.
A string.
Exampleconst optionElement = document.getElementById("exampleOption");
console.log(`Text property: ${optionElement.text}`);
optionElement.text = "Updated text";
Specifications Browser compatibility See also
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4