DOM Properties
HTMLSelectElement.selectedOptions
Read-only live collection. Provides currently selected option elements, including multiple selections. Map the collection to values for a snapshot; unlike the select value property it can represent more than one choice. Example result: a,b.
Formal Syntax & Structure
html syntaxhtml
element.selectedOptionsReturn Value
HTMLCollection
Property value. Read-only live collection.
Working Example
Example Snippethtml
<select id="demo" multiple> <option selected value="a">A</option> <option selected value="b">B</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(Array.from(e.selectedOptions,o=>o.value).join(','));</script>