jquery擷取radio值

來源:互聯網
上載者:User

標籤:http   io   os   ar   for   sp   on   cti   ad   

單選組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.111cn.net) $("#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>
from:http://www.111cn.net/wy/jquery/jquery-radio.htm

jquery擷取radio值

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.