Try
var tester = document.getElementById('tester');
var text = tester.options[tester.selectedIndex].innerHTML;
Question
This gets the value of whatever is selected in my dropdown menu.
document.getElementById('tester').value
I cannot however find out what property to go after for the text that's currently displayed by the drop down menu. I tried "text" then looked at W3Schools but that didn't have the answer, does anybody here know?
For those not sure, here's the HTML for a drop down box.
<select name="tester" id="tester">
<option value="1">A skill</option>
<option value="2">Another skill</option>
<option value="3">Yet another skill</option>
</select>
Thanks
La solution
Try
var tester = document.getElementById('tester');
var text = tester.options[tester.selectedIndex].innerHTML;
Autres conseils
Text looks good to me - jsFiddle
$('#tester').on('change', function(){
console.log($('option:selected', this).text());
});
I think you want something like this:
var d = document.getElementById('tester');
var selected_text = d.options[d.selectedIndex].text;
(this is untested, but your answer should be similar to this)