Hiding table data using

前端 未结 10 1057
轻奢々
轻奢々 2020-12-15 16:22

So, I\'ve hidden whole tables like this, which works fine:

相关标签:
10条回答
  • 2020-12-15 16:48

    Instead of using <div>, it would be better to use to provide the <tr> (which you want to hide) an id and then hiding it using javascript.

    0 讨论(0)
  • 2020-12-15 16:53

    Wrap the sections you want to hide in their own tbody and dynamically show/hide that.

    0 讨论(0)
  • 2020-12-15 16:55

    Unfortuantely, as div elements can't be direct descendants of table elements, the way I know to do this is to apply the CSS rules you want to each tr element that you want to apply it to.

    <table>
    <tr><th>Test Table</th><tr>
    <tr><td>123456789</td><tr>
    <tr style="display: none; other-property: value;"><td>123456789</td><tr>
    <tr style="display: none; other-property: value;"><td>123456789</td><tr>
    <tr><td>123456789</td><tr>
    <tr><td>123456789</td><tr>
    </table>
    

    If you have more than one CSS rule to apply to the rows in question, give the applicable rows a class instead and offload the rules to external CSS.

    <table>
    <tr><th>Test Table</th><tr>
    <tr><td>123456789</td><tr>
    <tr class="something"><td>123456789</td><tr>
    <tr class="something"><td>123456789</td><tr>
    <tr><td>123456789</td><tr>
    <tr><td>123456789</td><tr>
    </table>
    
    0 讨论(0)
  • 2020-12-15 17:01

    Give all the rows you want to hide a class name that you can use for hiding. Use javascript to add/remove this class from the different rows.

    <table>
    <tr><th>Test Table</th><tr>
    <tr class="toHide"><td>123456789</td><tr>
    <tr class="toHide"><td>123456789</td><tr>
    <tr class="toHide"><td>123456789</td><tr>
    </table>
    

    CSS:

    .toHide
    {
     display: none;
    }
    
    0 讨论(0)
提交回复
热议问题
Test Table