将Jquery手风琴扩展为表格的行 [英] Extending Jquery accordion to rows of a table
本文介绍了将Jquery手风琴扩展为表格的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一张可折叠行的表格。请查看此处
I have a table with collapsible rows. Please check here
I只想使用如图所示的Jquery UI手风琴这里
I just want to use the Jquery UI accordion as shown here
我正在尝试将accordion应用于以下结构:
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.
请建议。
推荐答案
使用手风琴的标题选项:
$(document).ready(function () {
$('table').accordion({header: '.category' });
});
https://jsfiddle.net/c1j7xbkp/
这篇关于将Jquery手风琴扩展为表格的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文