简体   繁体   English

表行折叠/展开css

[英]table rows collapse/expand css

I am using the following example Demo provided by PSL in a post on a website. 我在网站上的帖子中使用了PSL提供的以下示例演示

I have a large table and I don't want all of the rows to show when page loads just the headers. 我有一个大表,我不希望页面只加载标题时显示所有行。

Should I change the border-collapse:collapse; 我应该改变border-collapse:collapse; property in the css ? 在css的财产?

on dom ready you can hide the non header tr elements 在dom准备好你可以隐藏非标题tr元素

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

Demo: Fiddle 演示: 小提琴

Or using CSS 或者使用CSS

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

make sure that the default toggle is set to <span>+</span> 确保将默认切换设置为<span>+</span>

Demo: Fiddle 演示: 小提琴

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM