Is it possible to hide / show table columns by changing the CSS class on the col element only?

前端 未结 3 2008
执笔经年
执笔经年 2021-01-12 01:02

I\'m trying to hide / show columns in a table based on users choices during runtime. I defined two CSS classes:

.hide { visibility: collapse; }

.show { visi         


        
3条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-12 01:37

    I think the better choice is to use colgroup on your table and modify the css attributes to show or hide a column or a set of columns. For example, you would hide the first five columns like below:

        ...
    

    And you would modify the attribute by JQuery like below:

        $("#filterTableColgroup").css('visibility', 'collapse');
    

    提交回复
    热议问题
    ...