Select waarde eigenschap

Definitie en gebruik

value Instellen of retourneren van de waarde van de geselecteerde optie in de keuzelijst.

Zie ook:

HTML referentiemanual:HTML <select> tag

Voorbeeld

Voorbeeld 1

Verander de geselecteerde optie naar "banana":

document.getElementById("mySelect").value = "banana";

Probeer het zelf

Voorbeeld 2

Geef de waarde van de geselecteerde optie in de keuzelijst terug:

var x = document.getElementById("mySelect").value;

Probeer het zelf

syntaxis

Geef de waarde-eigenschap terug:

selectObject.value

Stel de waarde-eigenschap in:

selectObject.value = value

eigenschapswaarde

waarde omschrijving
value

Specifies the value of the <option> element in the dropdown list that should be selected.

If the value does not exist, the dropdown list will display an empty option.

Technical details

Return value:

String value, representing the value attribute of the <option> element in the dropdown list.

If the dropdown list allows multiple selections, the first selected option is returned.

If no option is selected, no content is returned.

Browser support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support