jquery獲取radio值(單選組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
單選組 radio: $("input[@type=radio]").attr("checked",'2');//設置value=2的項目為當前選中項
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();
(www.dhdzp.com) $("#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中的prototype和__proto__的理解
這篇文章主要介紹了淺談javascript中的prototype和__proto__的理解,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2019-04-04
使用Visual?Studio?2022開發(fā)前端的詳細教程
這篇文章主要介紹了使用Visual?Studio?2022開發(fā)前端,在瀏覽器中可以使用CDN源引用需要的客戶端庫,可如果在企業(yè)內網使用,無法訪問CDN源時,需要將客戶端庫下載到本地使用,需要的朋友可以參考下2022-05-05
Js使用WScript.Shell對象執(zhí)行.bat文件和cmd命令
這篇文章主要介紹了Js使用WScript.Shell對象執(zhí)行.bat文件和cmd命令,需要的朋友可以參考下2014-12-12

