Suppose I have a select
tag as following:
<select name='selectBox' id='selectBox'>
<option value='1'>one</option>
<option value='2'>two</option>
<option value='3'>three</option>
<option value='4'>four</option>
<option value='5'>five</option>
</select>
and I have a value in a variable, for example: selectVal = 'three'
and I want to select the option based on text
not on value
.
I looked on
$('#selectBox').prop('selectedIndex', 3);
$('#selectBox').selectmenu('refresh');
But I want to select on text
of option. I'm beginner in this stuff, any help will be highly appreciated!
Thanks.