I need to check if a <select>
has an option whose text is equal to a specific value.
For example, if there's an <option value="123">abc</option>
, I would be looking for "abc".
Is there a selector to do this?
Im looking for something similar to $('#select option[value="123"]');
but for the text.
None of the previous suggestions worked for me in jQuery 1.7.2 because I'm trying to set the selected index of the list based on the value from a textbox, and some text values are contained in multiple options. I ended up using the following:
This work for me
Either you iterate through the options, or put the same text inside another attribute of the option and select with that.