色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

jquery獲取radio值實例

本文實例講述了jquery獲取radio值的方法,分享給大家供大家參考。具體如下:

單選組radio: 復制代碼 代碼如下:$("input[@type=radio][@checked]").val();

單選組 radio: 復制代碼 代碼如下:$("input[@type=radio]").attr("checked",'2');//設置value=2的項目為當前選中項

獲取一組radio被選中項的值
復制代碼 代碼如下:var item = $('input[@name=items][@checked]').val();

radio單選組的第二個元素為當前選中值
復制代碼 代碼如下:$('input[@name=items]').get(1).checked = true

jquery老的版本
復制代碼 代碼如下:var_name = $("input[@name='radio_name']:checked").val();
jquery 1.3以后的版本
復制代碼 代碼如下:var_name = $("input[name='radio_name']:checked").val();

獲取radio值的jquery實例:

復制代碼 代碼如下:function getra(){

var_name = $("input[name='isspecialcnt']:checked").val();
//alert(var_name);
if(var_name=='1'){
$("#isspecialcntyes").show();
$("#isspecialcntno").hide();
}
if(var_name=='0'){
$("#isspecialcntyes").hide();
$("#isspecialcntno").show();
}
}

<form name="form1" method="post" action="">
<p>
<label>
<input type="radio" name="radiogroup1" value="單選" id="radiogroup1_0">
單選</label>
<br>
<label>
<input type="radio" name="radiogroup1" value="單選" id="radiogroup1_1">
單選</label>
<br>
<label>
<input type="radio" name="radiogroup1" value="單選" id="radiogroup1_2">
單選</label>
<br>
<label>
<input type="radio" name="radiogroup1" value="單選" id="radiogroup1_3">
單選</label>
<br>
<label>
<input type="radio" name="radiogroup1" value="單選" id="radiogroup1_4">
單選</label>
<br>
<label>
<input type="radio" name="radiogroup1" value="單選" id="radiogroup1_5">
單選</label>
<br>
</p>
</form>

希望本文所述對大家的Javascript程序設計有所幫助。

JavaScript技術jquery獲取radio值實例,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 正蓝旗| 富蕴县| 益阳市| 永吉县| 长宁区| 太白县| 利辛县| 论坛| 西宁市| 米泉市| 上思县| 和林格尔县| 濉溪县| 辛集市| 平潭县| 威信县| 临漳县| 汉沽区| 西丰县| 永泰县| 阳江市| 咸宁市| 安徽省| 长顺县| 丰宁| 上虞市| 县级市| 洪雅县| 宁化县| 玛纳斯县| 新河县| 丰原市| 丽水市| 天津市| 桂林市| 岳池县| 柯坪县| 门源| 翼城县| 鞍山市| 徐水县|