jquery獲取radio值(單選組radio)
來源:易賢網(wǎng) 閱讀:1984 次 日期:2014-10-17 11:24:04
溫馨提示:易賢網(wǎng)小編為您整理了“jquery獲取radio值(單選組radio)”,方便廣大網(wǎng)友查閱!

單選組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實例

?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>

更多信息請查看IT技術專欄

更多信息請查看腳本欄目
易賢網(wǎng)手機網(wǎng)站地址:jquery獲取radio值(單選組radio)

2025國考·省考課程試聽報名

  • 報班類型
  • 姓名
  • 手機號
  • 驗證碼
關于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點 | 投訴建議
工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網(wǎng)安備53010202001879號 人力資源服務許可證:(云)人服證字(2023)第0102001523號
聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關注公眾號:hfpxwx
咨詢QQ:1093837350(9:00—18:00)版權所有:易賢網(wǎng)