I have the following select element:
<select name="sub-concUnit" class="select form-control" required id="id_sub-concUnit">
<option value="" selected></option>
<option value="22">mg/ml</option>
<option value="23">µg/ml</option>
<option value="24">mM</option>
<option value="25">µM</option>
</select>
I need to get the value of the option with the text 'mg/ml'
. Note that 'mg/ml'
is not the selected option.
The idea is to be able to do something like this:
var sel = Get option value for which text is mg/ml;
$("#id_sub-concUnit").val(sel);
Right now, I have to hard code the value of the option with text mg/ml.
I have tried:
var sel = $("id_sub-concUnit").find('option[text="mg/ml"]');
as suggested here, but this returns an empty object.