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.dbjr.com.cn) $("#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>
相關文章
微信小程序開發(fā)之錄音機 音頻播放 動畫實例 (真機可用)
這篇文章主要介紹了微信小程序開發(fā)之錄音機 音頻播放 動畫實例 (真機可用),這里整理了詳細的代碼,有需要的小伙伴可以參考下。2016-12-12JS使用parseInt解析數(shù)字實現(xiàn)求和的方法
這篇文章主要介紹了JS使用parseInt解析數(shù)字實現(xiàn)求和的方法,涉及javascript表單元素值的獲取及parseInt解析轉換字符串為數(shù)字的技巧,具有一定參考借鑒價值,需要的朋友可以參考下2015-08-08