How do you get the currently selected <option> in a <select> via JavaScript?

Viewed 119436

How do you get the currently selected <option> of a <select> element via JavaScript?

4 Answers

Using the selectedOptions property:

var yourSelect = document.getElementById("your-select-id");
alert(yourSelect.selectedOptions[0].value);

It works in all browsers except Internet Explorer.

Related