I’d like to select a dropdown list’s value by its HTML. For example, I have the following selections…
<select id="dropdown">
<option value=""></option>
<option value="1">Choice 1</option>
<option value="2">Choice 2</option>
</select>
Right now I am able to retrieve the text Choice 1. I understand that I can select the corresponding value using $('#dropdown').val('1');. However, I don’t actually have access to 1, and I’d like to select that same selection just using Choice 1.
Is this possible via jQuery, or is there any other solution?
Iterate through the options and check the corresponding value
JSFIDDLE