- 相關(guān)推薦
JQuery 獲取和設(shè)置Select選項(xiàng)的代碼精選
獲取Select :
獲取select 選中的 text :
$("#ddlRegType").find("option:selected").text();
獲取select選中的 value:
$("#ddlRegType ").val();
獲取select選中的索引:
$("#ddlRegType ").get(0).selectedIndex;
設(shè)置select:
設(shè)置select 選中的索引:
$("#ddlRegType ").get(0).selectedIndex=index;//index為索引值
設(shè)置select 選中的value:
$("#ddlRegType ").attr("value","Normal“);
$("#ddlRegType ").val("Normal");
$("#ddlRegType ").get(0).value = value;
設(shè)置select 選中的text:
var count=$("#ddlRegType option").length;
for(var i=0;i<count;i++)
{ if($("#ddlRegType ").get(0).options[i].text == text)
{
$("#ddlRegType ").get(0).options[i].selected = true;
break;
}
}
清空 Select:
$("#ddlRegType ").empty();
【JQuery 獲取和設(shè)置Select選項(xiàng)的代碼】相關(guān)文章:
jquery提交按鈕的代碼07-28
基于jQuery的固定表格頭部的代碼08-30
jQuery(js)如何獲取文字寬度(顯示長(zhǎng)度)09-29
關(guān)jQuery彈出窗口簡(jiǎn)單實(shí)現(xiàn)代碼-javascript編程06-07
jQuery中parent()和siblings()的問(wèn)題10-16
ppt動(dòng)作按鈕設(shè)置和動(dòng)畫(huà)動(dòng)作設(shè)置12-06