Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

HTMLSelectElement.value — selected option value

HTMLSelectElement.value reads the first selected option's value or changes the selection by matching a value.

Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support

Syntax

select.value
select.value = "value"

HTMLSelectElement.value returns a string: the first selected option's value in tree order, or "" when none is selected. An option's value comes from its value attribute, or its text when that attribute is absent.

Assignment selects only the first matching option and deselects the others, even with multiple. No match clears the selection: value becomes "" and selectedIndex becomes -1.

With multiple, reading still returns one value, not an array; selectedOptions exposes all selected options. "" alone cannot distinguish no selection from a selected option with an empty value.

Examples

const select = document.createElement("select");
select.add(new Option("Alpha", "a"));
select.add(new Option("Beta", "b"));

select.value = "b";
console.log(JSON.stringify(select.value));

select.value = "missing";
console.log(JSON.stringify(select.value));
console.log(select.selectedIndex);

Result

"b"
""
-1

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources