In the following:
<select id="test">
<option value="1">Test One</option>
<option value="2">Test Two</option>
</select>
How can I get the text of the selected option (i.e. "Test One" or "Test Two") using JavaScript
document.getElementsById('test').selectedValue
returns 1 or 2, what property returns the text of the selected option?
If you use jQuery then you can write the following code:
Similar to @artur just without jQuery, with plain javascript:
// Using @Sean-bright's "elt" variable
You can use
selectedIndex
to retrieve the current selectedoption
:If you found this thread and wanted to know how to get the selected option text via event here is sample code: