亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何獲取radio單選是選中哪一個?

如何獲取radio單選是選中哪一個?

慕的地8271018 2018-07-07 14:18:32
<input name="dt" type="radio" id="first"/><input name="dt" type="radio" id="second"/>勾選了first,jq獲取兩個input返回都是on,要怎么知道假如我勾選了first,就獲取first
查看完整描述

2 回答

?
qq_遁去的一_1

TA貢獻1725條經驗 獲得超8個贊

<script src="jquery-1.12.4.js"></script>
<input name="dt" type="radio" id="first"/>
<input name="dt" type="radio" id="second"/>
<div onclick="i1()">查看1的狀態</div>
<div onclick="i2()">查看2的狀態</div>
<div onclick="who()">查看誰被選中</div>
<script>
const jqDom1 = $("#first");
const jqDom2 = $("#second");
function i1(){
    alert(jqDom1.prop("checked"));
}function i2(){
    alert(jqDom2.prop("checked"));
}function who(){
    alert($("input[name='dt']:checked").attr("id"));
}
</script>


查看完整回答
反對 回復 2018-07-14
?
搖曳的薔薇

TA貢獻1793條經驗 獲得超6個贊

$("input[name='dt'] :checked").val();


查看完整回答
反對 回復 2018-07-14
  • 2 回答
  • 0 關注
  • 1760 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號