admin管理员组文章数量:1303640
I have a table which is pretty big, so I need a way to unfold it all the time, and unfold it only necessary.
How can I do that with HTML? Do I need Javascript for this? If so, what's the code for this?
I have a table which is pretty big, so I need a way to unfold it all the time, and unfold it only necessary.
How can I do that with HTML? Do I need Javascript for this? If so, what's the code for this?
Share Improve this question asked Jul 24, 2010 at 16:27 prosseekprosseek 191k227 gold badges583 silver badges885 bronze badges 2- Can you give some sort of example? Im not too sure what you mean by folding/unfolding a table – barrylloyd Commented Jul 24, 2010 at 16:42
- 1 Why don't you add paging instead of folding / unfolding? That way you could keep the data cached and display only the current page. Then you wouldn't have to worry about poor performance. – Dan Stocker Commented Jul 24, 2010 at 16:45
3 Answers
Reset to default 2If you will use jquery you can check the code below.
In css:
.collapsed-table tr {
display: none;
}
In html:
<script type="text/javascript" src="http://ajax.googleapis./ajax/libs/jquery/1.4/jquery.min.js"></script>
<table class="collapsed-table">
<caption>Expand/collapce</caption>
<tr>
<td></td>
</tr>
....
</table>
<script type="text/javascript">
$('.collapsed-table > caption').click(function() {
$(this).toggleClass('collapsed-table');
})
</script>
Keep the header (thead) visible at all times and toggle the visibility of the body (tbody) when the user clicks on the folding button.
Using jQuery:
$('#foldbutton').click(function()
{
$('tbody').toggle();
});
I know it's an old question but others can have the same problem and no one have provided a plete solution, so if you want to fold / unfold something with an animation, I developed a script named TextShower that allows you to do that. It's highly customizable and you can edit its source freely. Hope this helps :)
本文标签: FoldingUnfolding table with HTMLJavascriptStack Overflow
版权声明:本文标题:FoldingUnfolding table with HTMLJavascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741728265a2394724.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论