Name

HTMLOptionElement — an <option> in an HTML form

Availability

DOM Level 1 HTML

Inherits from/Overrides

Node Element HTMLElement HTMLOptionElement

Properties

boolean defaultSelected

The initial value of the selected attribute of the <option> element. If the form is reset, the selected property is reset to the value of this property. Setting this property also sets the value of the selected property.

boolean disabled

If true, this option is disabled and the user is not allowed to select it. Mirrors the disabled attribute.

readonly HTMLFormElement form

A reference to the <form> element that contains this element.

readonly long index

The position of this <option> element within the <select> element that contains it.

String label

The text to be displayed for the option. Mirrors the label attribute. If this property is not specified, the plain-text content of the <option> element is used instead.

boolean selected

The current state of this option: if true, the option is selected. The initial value of this property comes from the selected attribute.

readonly String text

The plain text contained within the <option> element. This text appears as the label for the option.

String value

The value submitted with the form if this option is selected when form submission occurs. Mirrors the value attribute.

Description

This interface describes an <option> element within a <select> element.

Get JavaScript: The Definitive Guide, Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.