Reputation:
<select id='mySelect'>
<option value='FirstOption'>
Option 1
</option>
<option value='SecondOption'>
Option 2
</option>
</select>
I'd like to select the 2nd option based on the fact it has the word 'Second' in it's name.
What I've Tried
$('#mySelect').val('SecondOption');
Closest I've got. Obviously returns second option, but wouldn't work for 'AnotherSecondOption'
Upvotes: 0
Views: 1237
Reputation: 57105
Try * attribute-contains-selector
$('#mySelect option[value*="Second"]').prop('selected',true);
Upvotes: 2