gpt4 book ai didi

jQuery 检查 TD 内的右侧复选框

转载 作者:行者123 更新时间:2023-12-01 01:36:07 25 4
gpt4 key购买 nike

您可以在这里查看我的问题http://jsfiddle.net/eWh5F/76/ ()我想要的是单击 TD,并且应该选中/取消选中复选框对于 TD 内的复选框工作正常,但是当我在 TD 内有一个表并且在其中有 TD 时,有什么解决方案吗?我已经尝试过下面这样的东西,但没有运气

$("td").click(function(e) {
var checkbox = $(':checkbox', $(this).parent()).get(0);
var checked = checkbox.checked;
if (checked == false) checkbox.checked = true;
else checkbox.checked = false;});

最佳答案

您可以使用prop方法:

$("td").click(function(e) {
$('> input[type=checkbox]', this).prop('checked', function(i, checked){
return !checked
})
});

http://jsfiddle.net/jdy3d/

请注意,:checkbox 选择器已弃用。

关于jQuery 检查 TD 内的右侧复选框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13280049/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com