获取Select :
获取select 选中的 text:
$("#select_id”).find("option:selected”).text();
获取select选中的 value:
$("#select_id option:selected”).val();
($("#select_id”).val();这个方法是错误的)
获取select选中的索引:
$("#select_id ").get(0).selectedIndex;
设置select:
设置select 选中的索引:
$("#select_id ").get(0).selectedIndex=index;//index为索引值
设置select 选中的value:
$("#select_id ").attr("value”,”Normal");
$("#select_id ").val("Normal”);
$("#select_id ").get(0).value = value;
设置select 选中的text:
var count=$("#select_id ").find("option”).length;
for(var i=0;i<count;i++)
{
if($("#select_id ").get(0).options[i].text == text)
{
$("#select_id ").get(0).options[i].selected = true;
break;
}
}
select根据value默认选中
$("#SelectID option[value='selectValue']").attr("selected”,true)
清空 Select:
$("#select_id ").empty();
$("#veg1″).find("option”).clone().appendTo("#veg2″); 添加另一个select option
$("#veg2″).get(0).selectedIndex=2; 设置选中项