Firefox Tomorrow

web api instance property

HTMLOptionElement: text property

View on MDN ↗

The text property of the HTMLOptionElement represents the text inside the <option> element. This property represents the same information as 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.

Value

A string.

Example

const optionElement = document.getElementById("exampleOption");
console.log(`Text property: ${optionElement.text}`);
optionElement.text = "Updated text";

Specifications

SpecificationsStandards references are available on the canonical MDN page.

Browser compatibility

Browser compatibilityCompatibility data is available on the canonical MDN page.

See also