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

Paul D. Waite picture Paul D. Waite · Jul 21, 2010 · Viewed 106.5k times · Source

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

Answer

Pat picture Pat · Jul 21, 2010

This will do it for you:

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