DOM Interfaces
HTMLOptionElement
Represents one option in a select, optgroup or datalist and exposes its text, value and selected state. The selected property is current state; defaultSelected reflects the selected markup attribute. Example result: true.
Formal Syntax & Structure
html syntaxhtml
const element = document.getElementById('demo'); // HTMLOptionElementReturn Value
HTMLOptionElement
An existing HTML DOM object associated with the option element in this example; this interface is a type, not a function return contract.
Working Example
Example Snippethtml
<select> <option id="demo" value="a" selected>Alpha</option></select><p> Result: <output id="result"></output></p><script> const e = document.getElementById('demo'); const result = value => { document.getElementById("result").textContent = String(value); }; result(e.selected);</script>