Back to Content

HTMLOptionElement: defaultSelected property

files/en-us/web/api/htmloptionelement/defaultselected/index.md

latest810 B
Original Source

{{ APIRef("HTML DOM") }}

The defaultSelected property of the {{DOMxRef("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

A boolean.

Examples

js
const optionElement = document.getElementById("water");
console.log(optionElement.defaultSelected);

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also

  • {{HTMLElement("option")}}
  • {{DOMxRef("HTMLOptionElement.selected")}}
  • {{DOMxRef("HTMLOptionElement.index")}}
  • {{DOMxRef("HTMLOptionsCollection")}}
  • {{cssxref(":default")}}