【发布时间】:2014-02-26 16:28:48
【问题描述】:
我阅读了很多问题,但与我的情况不符。 这是我的表结构
如果我想隐藏代码下面的列 A 或 B 对我有用。
$('table td:nth-child(1),table th:nth-child(1)').hide();
$('table td:nth-child(2),table th:nth-child(2)').hide();
但如果我想删除 C 或更高版本的列,它会给我带来问题。 就像下面的代码给了我非相关的输出。
$('table td:nth-child(3),table th:nth-child(3)').hide();
请为此Link寻找小提琴
【问题讨论】:
-
你能做个小提琴吗?
-
当然。您正在删除第三个孩子 - 在中间列,您还需要删除第四个孩子。
-
第三个你也需要隐藏第四个
-
如果您知道需要隐藏哪些列,如何将特定的 CSS 类添加到要隐藏的列并使用
$('.toggle-column1').toggle();显示/隐藏这些? -
查看带有两个可切换列组的示例小提琴(刚刚更新):jsfiddle.net/Moonbird_IT/g2rym/1
标签: jquery html css css-selectors