说我有一个id为“唯一”的表并且我已经执行了
$('.8').hide();
$('.3').hide();
现在我只想显示具有 1 个可见列的行并隐藏其余行,即我想隐藏除第一行以外的所有行(仍然隐藏第二和第三列),我如何检查表行有超过 1 个可见列?
<table id="unique">
<tr class = "opponent4 opponent3 opponent5">
<td class="1">1</td>
<td class="3">3</td>
<td class="8">8</td>
</tr>
<tr class = "opponent7 opponent3 opponent9">
<td class="1">1</td>
<td class="1">1</td>
<td class="8">8</td>
</tr>
<tr class = "opponent1 opponent3 opponent4">
<td class="1">1</td>
<td class="2">2</td>
<td class="8">8</td>
</tr>
最佳答案
获取 TR 数组。过滤掉包含 1 个可见 TD 的那些。隐藏其余部分。
$("#unique tr").filter(function() { return $(this).find("td:visible").length != 1}).hide();
关于javascript - 如何检查表行是否只有 1 个可见表列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8996770/