代码之家  ›  专栏  ›  技术社区  ›  ahmet2106

对包含多个tbody的HTML表进行排序(每个tbody都包含col-&rowspan)

  •  1
  • ahmet2106  · 技术社区  · 16 年前

    现在我有了一个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和:偶来设置不同颜色组的样式,现在的问题是:我将对Tbody而不是TRs进行排序,因为这将导致错误(看起来不太好)

    http://tablesorter.com/docs/ 这是我第一次尝试,但这只适用于TR,因为我已经用TR更改了tbody,但现在我不能使用:奇和:偶,而且分类器没有运行,因为TR中有TR,我不知道为什么,但什么都没有发生。

    有没有一种方法可以将两个或多个tr分组,比如tbody,但是在哪里可以使用Tablesorter?

    2 回复  |  直到 14 年前
        1
  •  2
  •   Renato Albano    15 年前

    要使用多个tbodies的tablesorter fork: http://github.com/renatoalbano/jquery-tablesorter/

        2
  •  -2
  •   Zach    16 年前

    <tr> 在另一个里面 <tr> <tbody> 似乎不合适。假设您需要在表行中具有表结构,我认为您最好使用以下嵌入式表:

    <table>
      <thead>
      ...
      </thead>
      <tbody>
        <tr>
          <table>
          ...
          <table>
        </tr>
        <tr>
          <table>
          ...
          <table>
        </tr>
      </tbody>
    </table>