看了很多教程,包括csdn和stackoverflow,发现很多人都说使用attr('selected',true)来设置。但是这样做有一个问题,当使用find('select option:selected')来获取选中option的值的时候,会有一个default的option值加上一个使用attr('selected',true)的值,导致一些奇奇怪怪的问题。
解决方法:
$("select").get(0).selectedIndex=index; //index为想要设置选中的索引
再使用find('select option:selected')便能正确获取当前选中的值。