Jquery 调整大小时隐藏表td

Jquery 调整大小时隐藏表td,jquery,html-table,Jquery,Html Table,当我调整窗口大小或屏幕尺寸较小时,我想隐藏一些表td。 我尝试了CSS媒体查询 th:nth-last-child(-n+7) {display:none} td:nth-last-child(-n+7) {display:none} th:last-child {display:none} td:last-child {display:none} 它可以工作,但是CSS不能计算td,所以如果一个表只有三个td,那么上面的代码将隐藏所有三个td。 请帮助我使用jQuery实现这一点: 在调整大

当我调整窗口大小或屏幕尺寸较小时,我想隐藏一些
表td
。 我尝试了CSS
媒体查询

th:nth-last-child(-n+7) {display:none}
td:nth-last-child(-n+7) {display:none}
th:last-child {display:none}
td:last-child {display:none}
它可以工作,但是CSS不能计算td,所以如果一个表只有三个
td
,那么上面的代码将隐藏所有三个
td
。 请帮助我使用jQuery实现这一点: 在调整大小或屏幕尺寸较小时隐藏
td

  • 如果屏幕宽度为768px,则仅显示六个
    td
    ,并隐藏其他 右侧

  • 如果屏幕宽度为480px,则仅显示四个
    td
    ,并隐藏其他 右侧

  • 如果屏幕宽度为320px,则仅显示三个
    td
    并隐藏其他 从右边


  • 使用
    :最后一个子项
    最大宽度
    媒体查询

    td:n子(n+7)
    将仅影响以行中第七个单元格开始的单元格,
    td:n子(n+5)
    将仅影响以行中第五个单元格开始的单元格,依此类推

    @media (max-width:768px) {
        td:nth-child(n+7),th:nth-child(n+7) {display:none}
    }
    @media (max-width:480px) {
        td:nth-child(n+5),th:nth-child(n+5) {display:none}
    }
    @media (max-width:320px) {
        td:nth-child(n+4),th:nth-child(n+4) {display:none}
    }
    

    哈哈,我太笨了,错过了这个简单的步骤。谢谢@Blazemonger