獲取值:
文本框,文本區(qū)域:$("#username").attr("value");
多選框checkbox:$("#checkbox_id").attr("value");
單選組radio: $("input[@type=radio][@checked]").val();
下拉框select: $('#departid').val();
<input type="radio" name="istop" value="1"/>
<input type="radio" name="istop" value="0"/>
獲取選中radio的值:var item = $("input[name=istop]:checked").val();
JQuery獲取和設(shè)置Select選項
選中第一項1:$("#departid").get(0).options[0].selected = true;
選中第一項2:$("#departid").get(0).selectedIndex = 0;
清空 Select : $("#departid").empty();
獲取Select :
獲取select 選中的 text :$("#departid").find("option:selected").text();
獲取select選中的 value: $("#departid").val();
獲取select選中的索引: $("#departid").get(0).selectedIndex;
設(shè)置select 選中的text:
var count=$("#departid option").length;
for(var i=0;i<count;i++)
{ if($("#departid").get(0).options[i].text == text)
{
$("#departid").get(0).options[i].selected = true;
break;
}
}
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請
點擊舉報。