Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/380.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 仅显示包含<;td>;并且有一个复选框?_Javascript_Jquery - Fatal编程技术网

Javascript 仅显示包含<;td>;并且有一个复选框?

Javascript 仅显示包含<;td>;并且有一个复选框?,javascript,jquery,Javascript,Jquery,如何仅显示包含且有复选框的表行 var myTable = '#testTable'; $(myTable).find('tr').has('checkbox:checked').has('td').show(); 谢谢试试这个: $('#testTable tr td input[type=checkbox]:checked').show(); $('#testTable>tr>td>input[type=checkbox]:checked').show(); // i

如何仅显示包含
且有复选框的表行

var myTable = '#testTable';

$(myTable).find('tr').has('checkbox:checked').has('td').show();
谢谢

试试这个:

$('#testTable tr td input[type=checkbox]:checked').show();

$('#testTable>tr>td>input[type=checkbox]:checked').show(); // if you want to make sure they are the direct descendants (only first descendant level)
试试这个:

$('#testTable tr td input[type=checkbox]:checked').show();

$('#testTable>tr>td>input[type=checkbox]:checked').show(); // if you want to make sure they are the direct descendants (only first descendant level)
是:

是:


您想显示/隐藏行而不仅仅是单元格,对吗

需要使用
.parent().parent()
返回到
tr
元素

$('#testTable>tr>td>input[type=checkbox]:checked').parent().parent().show();

您想显示/隐藏行而不仅仅是单元格,对吗

需要使用
.parent().parent()
返回到
tr
元素

$('#testTable>tr>td>input[type=checkbox]:checked').parent().parent().show();

有效地执行此操作取决于您在XPath查询中遍历要操作的节点这一事实。这意味着所有后续XPath查询实际上都应该作为过滤子搜索来完成。这是非常琐碎的事情;用方括号括起来就可以了(由于使用了
,所以添加了
):


有效地执行此操作取决于您在XPath查询中遍历要操作的节点这一事实。这意味着所有后续XPath查询实际上都应该作为过滤子搜索来完成。这是非常琐碎的事情;用方括号括起来就可以了(由于使用了
,所以添加了
):


谢谢-以及如何确保其在一行中的tat具有sthanks?以及如何确保其在一行中的tat具有SPLESE添加一个示例html代码。请添加一个示例html代码。parents()如果#testTable嵌套在另一个表中,那么可能会把事情搞砸吗?我不这么认为,因为它与调用它的表相关-有人知道吗?我认为最好用最近的('tr')替换父('tr')Hello World:不,它与任何东西都不相关,它会以自己的方式备份整个DOM树。父()如果#testTable嵌套在另一个表中,那么可能会把事情搞砸吗?我不这么认为,因为它与调用它的表相关-有人知道吗?我认为最好用最近的('tr')替换父('tr')Hello World:不,它与任何东西都不相关,它以其方式备份整个DOM树。
$('#testTable>tr[.>td>input[type=checkbox]:checked]').show();