最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

jQuery中的RadioButton,input,CheckBox取值賦值實(shí)現(xiàn)代碼

 更新時(shí)間:2014年02月18日 10:13:27   作者:  
本篇文章主要是對(duì)jQuery中的RadioButton,input,CheckBox取值賦值實(shí)現(xiàn)代碼進(jìn)行了介紹,需要的朋友可以過來參考下,希望對(duì)大家有所幫助

1、jquery 獲取單選組radio
$("input[name='name']:checked").val();

2、jquery獲取radiobutton的下一個(gè)值
$("input[name='name']:checked").next().text()
$("input[name='name']:checked").val()

3、jquery 獲取input的值
$('#id').val()

4、jquery判斷多選框checkbox
$("#id:checkbox").attr("checked")
取值 $("#id").attr("value");
賦值則是在text()、val()里面直接給值

JQUERY如何獲取text,areatext,radio,checkbox,select值?
$("input").val();
$("textarea").text();
$("select").val();

控制表單元素:
文本框,文本區(qū)域:$("#txt").attr("value",'');//清空內(nèi)容
$("#txt").attr("value",'11');//填充內(nèi)容
多選框checkbox: $("#chk1").attr("checked",'');//不打勾
$("#chk2").attr("checked",true);//打勾
if($("#chk1").attr('checked')==undefined) //判斷是否已經(jīng)打勾

單選組radio: $("input[@type=radio]").attr("checked",'2');//設(shè)置value=2的項(xiàng)目為當(dāng)前選中項(xiàng)

下拉框select: $("#sel").attr("value",'-sel3');//設(shè)置value=-sel3的項(xiàng)目為當(dāng)前選中項(xiàng)
$("<option value='1'>1111</option><option value='2'>2222</option>").appendTo("#sel")//添加下拉框的option
$("#sel").empty();//清空下拉框

jQuery 獲取和設(shè)置select下拉框的值文章分類:.net編程

獲取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_id option[text='jQuery']").attr("selected", true);

設(shè)置select option項(xiàng):
$("#select_id").append("<option value='Value'>Text</option>"); //添加一項(xiàng)option
$("#select_id").prepend("<option value='0'>請(qǐng)選擇</option>"); //在前面插入一項(xiàng)option
$("#select_id option:last").remove(); //刪除索引值最大的Option
$("#select_id option[index='0']").remove();//刪除索引值為0的Option
$("#select_id option[value='3']").remove(); //刪除值為3的Option
$("#select_id option[text='4']").remove(); //刪除TEXT值為4的Option

清空 Select:
$("#ddlRegType ").empty();

相關(guān)文章

最新評(píng)論

云阳县| 中超| 南川市| 拉萨市| 册亨县| 楚雄市| 平江县| 三亚市| 册亨县| 盖州市| 鹰潭市| 三明市| 宣化县| 仁寿县| 融水| 贵德县| 贵德县| 河曲县| 酒泉市| 建水县| 锡林浩特市| 会同县| 梁山县| 亚东县| 崇左市| 灵台县| 贵溪市| 巴里| 大名县| 手机| 德昌县| 大姚县| 绍兴县| 嘉鱼县| 明溪县| 乐亭县| 嘉黎县| 德州市| 汾西县| 六枝特区| 涿州市|