对内部有多个 tbody 的 HTML 表进行排序(每个 tbody 都有 col-&rowspan)
我有一个问题:
现在我有一个 html 文件,其中包含如下内容:
<table>
<thead>
...
</thead>
<tbody>
<tr>
<td rowspan="2">demo</td>
<td rowspan="2">demo</td>
<td">demo</td>
<td>demo</td>
</tr>
<tr>
<td>demo</td>
<td>demo</td>
</tr>
</tbody>
<tbody>
<tr>
<td rowspan="2">demo</td>
<td rowspan="2">demo</td>
<td">demo</td>
<td>demo</td>
</tr>
<tr>
<td>demo</td>
<td>demo</td>
</tr>
</tbody>
</table>
使用 jQuery,我使用 :odd 和 :even 来设置具有不同颜色的组的样式,我现在的问题是:我将对 Tbody 进行排序,而不是TR,因为这会导致错误(看起来不太好)
有没有办法像 tbody 一样对两个或多个 TR 进行分组,但是我在哪里也可以使用 Tablesorter?
I've got a question:
Now i have a html file with some content like this:
<table>
<thead>
...
</thead>
<tbody>
<tr>
<td rowspan="2">demo</td>
<td rowspan="2">demo</td>
<td">demo</td>
<td>demo</td>
</tr>
<tr>
<td>demo</td>
<td>demo</td>
</tr>
</tbody>
<tbody>
<tr>
<td rowspan="2">demo</td>
<td rowspan="2">demo</td>
<td">demo</td>
<td>demo</td>
</tr>
<tr>
<td>demo</td>
<td>demo</td>
</tr>
</tbody>
</table>
With jQuery I'm using :odd and :even to style the groups with different colors, my Problem is now: I will Sort the Tbody and not the TRs, because this will cause a error (will not look good)
http://tablesorter.com/docs/ This was my first try, but this only works with TR, because of that I've changed tbody with TR, but now I cant use :odd and :even and also the sorter is not running, because there are TR in TR, I dont know why but nothing happens.
Is there a way to group two or more TRs like tbody but where can I also use a Tablesorter?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
另一个
内部的
对我来说似乎不是正确的 html。同样,有两个
似乎也不合适。假设您需要在表行中具有表结构,我认为最好的选择是使用像这样的嵌入表:
<tr>
inside of another<tr>
doesn't seem like proper html to me. Likewise, having two<tbody>
seems improper. Assuming you need to have table structure in your table rows, I think your best bet will be to use embedded tables like this:tablesorter fork 可以与多个 tbody 一起使用:
http://github.com/renatoalbano/jquery-tablesorter/
tablesorter fork to work with multiple tbodies:
http://github.com/renatoalbano/jquery-tablesorter/