将 Jquery 手风琴扩展到表的行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16046654/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Extending Jquery accordion to rows of a table
提问by Soumya
I have a table with collapsible rows. Please check here
我有一个带有可折叠行的表格。请检查这里
I just want to use the Jquery UI accordion as shown here
我只是想使用jQuery UI的手风琴如图所示这里
I am trying to apply accordion to the below structure :
我正在尝试将手风琴应用于以下结构:
<table>
<tbody class="category">
<tr><td>Category - 1</td></tr>
</tbody>
<tbody class="subcategory">
<tr><td>Sub Cateogry 1.1</td></tr>
<tr><td>Sub Cateogry 1.2</td></tr>
</tbody>
<tbody class="category">
<tr><td>Category - 2</td></tr>
</tbody>
<tbody class="subcategory">
<tr><td>Sub Cateogry 2.1</td></tr>
</tbody>
</table>
I understand that ordered list is most suitable for this type of structure.But due to some restrictions, table needs to be used.
我知道有序列表最适合这种类型的结构。但由于一些限制,需要使用表。
Please suggest.
请建议。
回答by Kaloyan
Use the headeroption of the accordion:
使用手风琴的标题选项:
$(document).ready(function () {
$('table').accordion({header: '.category' });
});