http://stackoverflow.com/questions/1280369/jquery-set-selected-option-using-next
Update:
As of jQuery 1.6+ you should use prop()
instead of attr()
in this case.
The difference between attributes and properties can be important in specific situations. Before jQuery 1.6, the .attr() method sometimes took property values into account when retrieving some attributes, which could cause inconsistent behavior. As of jQuery 1.6, the .prop() method provides a way to explicitly retrieve property values, while .attr() retrieves attributes.
var theValue = "whatever";
$("#selectID").val( theValue ).prop('selected',true);
Original Answer:
If you want to select by the value of the option, REGARDLESS of its position (this example assumes you have an ID for your select):
var theValue = "whatever";
$("#selectID").val( theValue ).attr('selected',true);
You do not need to "unselect". That happens automatically when you select another.