1.获取选中的下拉框的索引:
var index = document.getElementById("ID").selectedIndex;//得到选中项的索引
var department =document.getElementById("ID").options[index].text.trim();//得到选中项的text值
var department1 =document.getElementById("ID").options[index].value.trim();//得到选中项的Value值
2.获取相应的option的索引:
var maxIndex = $(“#select_id :last”).get(0).index; //获取select最大索引值
var checkIndex = $(“#select_id”).get(0).selectedIndex;//获取Select选中项的索引值
var checkIndexs = $(‘option:selected’, ‘#select_id’).index(); //获取选中的select的索引
var checkIndexa =('#select_id option').index(('#select_id option').index((‘#select_id option:selected’)); //获取选中的select的索引
var checkIndex = $(‘#select_id’).prop(‘selectedIndex’); //获取选中的select的索引
3.判断是否被选中:
alert($(“#select_id”).find(“option[value=’Value值’]”).is(“:selected”)); //选中为true 没选中为false
alert(document.getElementById(“select_id”).options[1].selected); //判断选中为true 没选中为false
4.获取相应option的值:
var checkValue = $(‘#select_id option:first’).val();//获取第一个option的值
var checkValue =$(“#select_id option:last”).val();//最后一个option的值
var checkValue = $(‘#select_id option:eq(1)’).val();//获取第二个option的值
5.禁用下拉框:
$("#ID").attr("disabled","disabled");//禁用下拉框
本人一般用得比较多的就是第一种和最后一种。