JQuery同步两个单选按钮组之间的选定单选按钮 [英] JQuery Sync Selected Radio Button between 2 radio button groups

查看:109
本文介绍了JQuery同步两个单选按钮组之间的选定单选按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道可以使用JQuery上的键盘粘贴在输入框上完成操作,但是单选按钮呢?

I know it can be done with input boxes using keyup paste on JQuery but what about Radio buttons?

示例:

用户从区域A(单选按钮)中选择选项,然后选择(同步)区域B

User Selects option from Area A (radio button) and it selects(syncs) area B

<!--AREA A (Source) -->
<input id="radio_A" name="radio_A" type="radio" value="Value1" />
<input id="radio_A2" name="radio_A" type="radio" value="Value2" />

<!--AREA B (Target)-->

<input id="radio_B" name="radio_B" type="radio" value="Value1" />
<input id="radio_B2" name="radio_B" type="radio" value="Value2" />

推荐答案

尝试一下:

$("#radio_A").click(function() {
    $("#radio_B").attr("checked", $(this).attr("checked"));
});
$("#radio_A2").click(function() {
    $("#radio_B2").attr("checked", $(this).attr("checked"));
});

小提琴示例

Example fiddle

这篇关于JQuery同步两个单选按钮组之间的选定单选按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆