Jquery 如何通过单击的最后一个中的复选框来取消选中中的所有复选框

Jquery 如何通过单击的最后一个中的复选框来取消选中中的所有复选框,jquery,Jquery,请给出我问题的解决办法 我有一张桌子 如果我选中了的最后一个标记中的复选框,那么同一个标记的所有复选框都应该取消勾选 我的代码现在是这样的 var columnText = $('TABLE TBODY TR:first TD:last input:checkbox').change( function() { alert("Hi"); $(this).parents('tr').find('input:checkbox').attr('checked', fa

请给出我问题的解决办法

我有一张桌子

如果我选中了的最后一个标记中的复选框,那么同一个标记的所有复选框都应该取消勾选

我的代码现在是这样的

var columnText = $('TABLE TBODY TR:first TD:last input:checkbox').change(
   function() {
      alert("Hi");  
      $(this).parents('tr').find('input:checkbox').attr('checked', false);
});
请任何人帮帮我-

谢谢。

试试这个:

var columnText = $('table tbody tr:first td:last input[type="checkbox"]').change(function(){
  alert("Hi");
  $(this).parents('tr').find('input[type="checkbox"]').attr('checked', false);
});
使用.closest选择器@和$each迭代器

$.each($(this).closest('tr').find("td"),function(){
   $(this).attr('checked', false);
});

如果我理解的问题是正确的,这里有一个表,在td中有一些复选框

<table id="check_test">
<tr><td>
<input type="checkbox" name="a" id="a" value=""/><label for="a">a</label>
<input type="checkbox" name="b" id="b" value=""/><label for="b">b</label>
<input type="checkbox" name="c" id="c" value=""/><label for="c">last</label>
</td></tr>
<tr><td>
<input type="checkbox" name="d" id="d" value=""/><label for="d">d</label>
<input type="checkbox" name="e" id="e" value=""/><label for="e">e</label>
<input type="checkbox" name="f" id="f" value=""/><label for="f">last</label>
</td></tr>
</table>

我猜这根本不起作用,因为你还没有说这是如何失败的。也许在复选框中添加一个类会更容易,而不是有一个如此复杂的选择器,它只对第一行有效,而对其他行无效。我不确定为什么要进行向下投票。。。此人显然是新用户,请提供建设性反馈并帮助用户使用stackoverflow社区…:pYour脚本在您发布时起作用:一定是出了什么问题,您没有向我们展示。非常感谢您的宝贵评论。
<table id="check_test">
<tr><td>
<input type="checkbox" name="a" id="a" value=""/><label for="a">a</label>
<input type="checkbox" name="b" id="b" value=""/><label for="b">b</label>
<input type="checkbox" name="c" id="c" value=""/><label for="c">last</label>
</td></tr>
<tr><td>
<input type="checkbox" name="d" id="d" value=""/><label for="d">d</label>
<input type="checkbox" name="e" id="e" value=""/><label for="e">e</label>
<input type="checkbox" name="f" id="f" value=""/><label for="f">last</label>
</td></tr>
</table>
$(document).ready(function() {
    $("#check_test td").find("input:last").change(function()                    
        $(this).parent().find(":checkbox").attr('checked',true);
    });
});