With jQuery, simply by retreiving the DOM node ...
$( <selector> ).get(0)
and use the native Javascript property
.selectedIndex
.
Set the index of the option (not the value) !
$( <selector> ).get(0).selectedIndex = <required-index>
When we have the option value, so use the CSS Attribute selector, and
.attr()
$( <selector> ).find('option[value="<required-value>"]').attr('selected','selected')
To fetch the index
(position of the option
in DOM tree) of an option by its value, use:
idx = $( <selector> ).find('option[value="<required-value>"]').index()
Note: the index position start at 0!