單選組radio: $("input[@type=radio][@checked]").val();
單選組radio: $("input[@type=radio]").attr("checked",'2');//設(shè)置value=2的項(xiàng)目為當(dāng)前選中項(xiàng)
獲取一組radio被選中項(xiàng)的值
var item = $('input[@name=items][@checked]').val();
radio單選組的第二個(gè)元素為當(dāng)前選中值
$('input[@name=items]').get(1).checked = true
單選組 radio: $("input[@type=radio]").attr("checked",'2');//設(shè)置value=2的項(xiàng)目為當(dāng)前選中項(xiàng)
jquery老的版本
var_name = $("input[@name='radio_name']:checked").val();
jquery 1.3以后的版本
var_name = $("input[name='radio_name']:checked").val();
看個(gè)獲取radio值的jquery實(shí)例
?123456789101112131415161718192021222324252627282930313233343536373839404142 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>
更多信息請(qǐng)查看IT技術(shù)專欄