I have a list like this:
<select name="select_list_name" id="list_id"> <option value="">Select Option</option> <option value="value1">Option 1</option> <option value="value2">Option 2</option> ... ... </select>
I am trying to get the text value of the currently selected parameter in the select list. I looked at this topic: jQuery get the specific text of the option tag and tried this:
$("#list_id option:selected").text()
But this only gives me the first text of the options ( "Select Option" ), regardless of which option was selected.
I tried another way:
$("[name=select_list_name] option:selected").text()
This gives me the first version of the text concatenated with the selected option text ( "Select OptionOption 2" if I select option 2).
Any idea on why?
Eqbal source share