HTMLOptionElement: defaultSelected property
MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونهکد
{{ 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](/en-US/docs/Web/HTML/Reference/Elements/option#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")}}