JavaScript - Get the text of the Selected Option
Posted: 04 May 2015, 10:38
I have a dropdown select list like this:
I can get the value with something like in JS:
But how can I get the actual option text using JavaScript?
Code: Select all
<select name="sel1" id="sel1">
<option value="1">text 1</option>
<option value="2">txt 2</option>
<option value="3">text 3</option>
</select>
Code: Select all
document.getElementById('sel1').addEventListener('change', function(e){
alert(this.value);
});