table rows collapse/expand css

前端 未结 1 594
-上瘾入骨i
-上瘾入骨i 2021-01-25 12:52

I am using the following example Demo provided by PSL in a post on a website.

I have a large table and I don\'t want all of the rows to show when page loads just the he

1条回答
  •  温柔的废话
    2021-01-25 13:23

    on dom ready you can hide the non header tr elements

    $('.header').find('span').text('+')
    $('table tr:not(.header)').hide()
    

    Demo: Fiddle

    Or using CSS

    tr.header {
        cursor:pointer;
        display: table-row;
    }
    tr {
        display: none;
    }
    

    make sure that the default toggle is set to +

    Demo: Fiddle

    0 讨论(0)
提交回复
热议问题