如何改变单选按钮到另一个时选择“检查"? [英] How to change radio button to 'checked' when another is selected?

查看:59
本文介绍了如何改变单选按钮到另一个时选择“检查"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望你们能帮我这个忙.

I hope you guys can help me with this one.

当单选按钮 id ="B" 时,如何使单选按钮 id ="A" 将其属性更改为已选中" >被选中?

How can I have a radio button id="A" change it's attribute to 'checked' when radio button id="B" is selected?

单选按钮A和B在不同的组中.

Radio buttons A and B are in different groups.

谢谢!

推荐答案

<input type="radio" name="group1" id="A">Radio A
<input type="radio" name="group2" id="B">Radio B
<input type="radio" name="group2" id="C">Radio C

$("input[type='radio'][name='group2']").change(function() {
  if ($('#B').is(':checked')) {
    $('#A').prop("checked", true);
  } else {
    $('#A').prop("checked", false);
  }
});

这是jsFiddle http://jsfiddle.net/8kdb7d6o/

Here is the jsFiddle http://jsfiddle.net/8kdb7d6o/

这篇关于如何改变单选按钮到另一个时选择“检查"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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