var obj = document.getElementById(“select”); //定位id
var idx= obj.selectedIndex; // 选中索引
var text = obj.options[index].text; // 选中文本
var value = obj.options[index].value; // 选中值
获得选中select值
第一种方式
$(’#select option:selected’).text();//选中的文本
$(’#select option:selected’) .val();//选中的值
$("#select").get(0).selectedIndex;//索引
第二种方式
$("#select").find(“option:selected”).text();//选中的文本
$("#select").find(“option:selected”).val();
$("#select").find(“option:selected”).get(0).selectedIndex;
value值默认选中
第一种方式:document.getElementById("id").value = "0"
;
第二种方式:$("#id").val("1")
;
回填值
比如<select class="selector"></select>
1、设置value为pxx的项选中
$(".selector").val("pxx");
2、设置text为pxx的项选中
$(".selector").find("option[text='pxx']").attr("selected",true);