Hiding columns in table JavaScript

后端 未结 3 1619
离开以前
离开以前 2020-12-10 12:01

This script stops working the moment I add a table inside a table, so how to get it worked? I don\'t need any jQuery solutions, I want pure JavaScript. Here\'s my sc

3条回答
  •  一向
    一向 (楼主)
    2020-12-10 12:27

    If you can leverage the col tag the solution, in pure JavaScript, is straightforward:

    2 two deux zwei
    3 three trois drei
    4 fourquattre vier
    5 five cinqfÜnf
    6 six six sechs

    You can apply to col just a couple of CSS attributes, but visibility is one of them:

    function show_hide_column(col_no, do_show) {
       var tbl = document.getElementById('id_of_table');
       var col = tbl.getElementsByTagName('col')[col_no];
       if (col) {
         col.style.visibility=do_show?"":"collapse";
       }
    }
    

    References:

    • col
    • visibility on quirksmode

提交回复
热议问题