How to hide columns in HTML table?

后端 未结 9 1000
执念已碎
执念已碎 2020-11-27 14:07

I have created a table in ASPX. I want to hide one of the columns based on the requirement but there is no attribute like visible in the HTML table building. Ho

相关标签:
9条回答
  • 2020-11-27 14:44

    You can also do what vs dev suggests programmatically by assigning the style with Javascript by iterating through the columns and setting the td element at a specific index to have that style.

    0 讨论(0)
  • 2020-11-27 14:45

    Bootstrap people use .hidden class on <td>.

    0 讨论(0)
  • 2020-11-27 14:54
    <!doctype html>
    <html lang="en">
    <head>
    <style id="myStyleSheet">
    ...
    </style>
    
    var column = 3;
    var styleSheet = document.getElementById("myStyleSheet").sheet;
    var rule = "table  tr td:nth-child("+ column +"),table th:nth-child("+ column +") 
    {display: none}";
    styleSheet.insertRule(rule);
    
    0 讨论(0)
提交回复
热议问题