Table of Contents

Class HTMLOptionElement

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll

The HTMLOptionElement interface represents {{HTMLElement("option")}} elements and inherits all properties and methods of the HTMLElement interface.

[Value("HTMLOptionElement")]
public class HTMLOptionElement : HTMLElement
Inheritance
HTMLOptionElement
Inherited Members

Remarks

Constructors

HTMLOptionElement()

public HTMLOptionElement()

Properties

DefaultSelected

The defaultSelected property of the HTMLOptionElement interface specifies the default selected state of the element. This property reflects the {{htmlelement("option")}} element's selected attribute. The presence of the selected attribute sets the defaultSelected property to true.

[Value("defaultSelected")]
public bool DefaultSelected { get; set; }

Property Value

bool

A boolean.

Remarks

Disabled

The disabled property of the HTMLOptionElement is a boolean value that indicates whether the {{htmlelement("option")}} element is unavailable to be selected. The property reflects the value of the disabled HTML attribute.

[Value("disabled")]
public bool Disabled { get; set; }

Property Value

bool

A boolean value.

Remarks

The property reflects the value of the disabled attribute on the <option> element itself. If an option is disabled because it is a child of an optgroup element that is disabled, the true of the Disabled property is not inherited by the option itself.

-option
-select
-optgroup
-Disabled
-Disabled
-Selected
-Index
-HTMLOptionsCollection
-:disabled

See also on MDN

Form

The form read-only property of the HTMLOptionElement interface returns an HTMLFormElement object that owns the HTMLSelectElement associated with this {{htmlelement("option")}}, or null if this option is not associated with a select owned by a form.

[Value("form")]
public HTMLFormElement? Form { get; }

Property Value

HTMLFormElement

An HTMLFormElement or null.

Remarks

Index

The read-only index property of the HTMLOptionElement interface specifies the 0-based index of the element; that is, the position of the {{HTMLElement("option")}} within the list of options it belongs to, in tree-order, as an integer. If the <option> is not part of an option-list, the value is 0.

[Value("index")]
public long Index { get; }

Property Value

long

A number.

Remarks

Label

The label property of the HTMLOptionElement represents the text displayed for an option in a {{htmlelement("select")}} element or as part of a list of suggestions in a {{htmlelement("datalist")}} element. It reflects the {{htmlelement("option")}} element's label attribute.

[Value("label")]
public string Label { get; set; }

Property Value

string

A string.

Remarks

If the attribute is omitted or the empty string, the label property returns the element's Text content.

-Value
-select
-datalist
-optgroup

See also on MDN

Selected

The selected property of the HTMLOptionElement interface specifies the current selectedness of the element; that is, whether the {{HTMLElement("option")}} is selected or not.

[Value("selected")]
public bool Selected { get; set; }

Property Value

bool

A boolean.

Remarks

The presence of the HTML selected attribute indicates the option is selected by default. It does not indicate whether this option is currently selected: if the option's state changes, the selected content attribute does not reflect the change; only the HTMLOptionElement's selected IDL property is updated. The selected attribute is reflected by the DefaultSelected property.

-option
-select
-DefaultSelected
-Index
-HTMLOptionsCollection
-SelectedIndex

See also on MDN

Text

The text property of the HTMLOptionElement represents the text inside the {{htmlelement("option")}} element.
This property represents the same information as TextContent.

[Value("text")]
public string Text { get; set; }

Property Value

string

A string.

Remarks

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.

-select
-datalist
-optgroup
-Value
-Label
-Text
-Text

See also on MDN

Value

The value property of the HTMLOptionElement interface represents the value of the {{htmlelement("option")}} element as a string, or the empty string if no value is set. It reflects the element's value attribute, if present. Otherwise, it returns or sets the contents of the element, similar to the TextContent property.

[Value("value")]
public string Value { get; set; }

Property Value

string

A string containing the value attribute value, if present, or the contents of the element.

Remarks