jQuery 取消选中同一行中选中的一个复选框上的其他复选框

Boy*_*yka 4 javascript checkbox jquery unchecked

您好,
我想告诉您,我知道关于相同问题的堆栈溢出有很多已解决的示例。但是我的查询有点复杂,让我感到恶心。我有大量由 10 行和 9 列组成的表。我想要的只是当用户选中“STROKE”的“NONE”复选框时,同一行中的其他复选框未选中。我必须为每一行执行此操作。如果选中“其他”复选框(用户可以选中多个“父母”、“叔叔”、“其他”等),则“无”复选框将取消选中。 如有疑问请问我。 我从过去两天开始就在尝试同样的事情,但可以成功。请帮助我提前致谢。

心 无 父母 叔叔/阿姨 祖父母 其他
================================================ =====================
中风    在此输入图像描述                在此输入图像描述                     在此输入图像描述                           在此输入图像描述                        在此输入图像描述
攻击     在此输入图像描述                在此输入图像描述                     在此输入图像描述                           在此输入图像描述                        在此输入图像描述
血压             在此输入图像描述                在此输入图像描述                     在此输入图像描述                           在此输入图像描述                        在此输入图像描述



血统 无 父母 叔叔/阿姨 祖父母 其他
================================================ =====================
贫血    在此输入图像描述                在此输入图像描述                     在此输入图像描述                           在此输入图像描述                        在此输入图像描述
免疫   在此输入图像描述                在此输入图像描述                     在此输入图像描述                           在此输入图像描述                        在此输入图像描述
卢克米亚   在此输入图像描述                在此输入图像描述                     在此输入图像描述                           在此输入图像描述                        在此输入图像描述

lal*_*mar 5

同一行使用相同的类。在每一行中,您可以给出不同的类名称,并进一步执行相同的操作。我给了您一行示例。

$(function(){
$("input[type='checkbox']").click(function(){
if($(this).prop('checked') == true && $(this).attr('class')=='none'){

$(this).closest("tr").find("input[type='checkbox']").each(function(){
$(this).prop('checked', false);
});
$(this).prop('checked',true);

}
else{
$(this).closest("tr").find("input[type='checkbox']").each(function(){
$(this).closest('.none').prop('checked',false);
});
}
});
});
Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table border='0'>
<tr><th>HEART</th><th>NONE</th><th>PARENT</th><th>UNCLE/AUNT</th><th>GRANDPARENT</th><th>OTHERS</th><tr>
<tr><td>STROKE</td><td><input type='checkbox' class='none'></td><td><input type='checkbox' class='stroke'></td><td><input type='checkbox' class='stroke'></td><td><input type='checkbox' class='stroke'></td><td><input type='checkbox' class='stroke'></td></tr>
<tr><td>ATTACK</td><td><input type='checkbox' class='none'></td><td><input type='checkbox' class='attack'></td><td><input type='checkbox' class='attack'></td><td><input type='checkbox' class='attack'></td><td><input type='checkbox' class='attack'></td></tr>
</table>
Run Code Online (Sandbox Code Playgroud)