I have a select with the following options:
<select>
<option value="1">A</option>
<option value="2">B</option>
<option value="3">C</option>
</select>
I don’t know what the values are, but in my JQuery code, I want to select option two because I know that the text is B (but nothing else).
How can it be done?
You can use the
:contains()selector:Alternatively: