jquery如何让select选中某个选项的实例详解
广州市
让select 选中 广州市 ?
错误用法:
$("#select_id option[text='广州市']").attr("selected", true);
$("#select_id option[text='广州市']").attr("selected", "selected");
正确用法:
$("#select_id")[0].selectedIndex = 1;jquery如何设置select索引选中,直接用dom操作方式操作索引:
$('#selectId').get(0).selectedIndex=index;用值方式操作索引:
$('#selectId').val('selectIndexValue');
扩展:
获取当前选中项的value
$("#select_id").val();获取当前选中项的text
$("#select_id").find("option:selected").text();










