Answer the question
In order to leave comments, you need to log in
Explain selectedOption please?
<select>
<option value="Rock">Рок</option>
<option value="Blues" selected>Блюз</option>
</select>
<script>
var select = document.body.children[0];
var selectedOption = select.options[select.selectedIndex]; //
alert( selectedOption.value + " - " + selectedOption.text );
</script>
Answer the question
In order to leave comments, you need to log in
select.options --- All possible options in array
select.selectedIndex --- index of selected option
selectedOption = array_options[ selected_index];
selectedOptions === {
value: 'option value',
text: 'option text',
...
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question