如何对html表中的列进行排序

时间:2015-12-14 15:41:12

标签: javascript jquery

我在html表格中显示数据。我只需要排序一列     https://jsfiddle.net/5a3j7ek1/

<iframe width="100%" height="300" src="//jsfiddle.net/5a3j7ek1/embedded/"  allowfullscreen="allowfullscreen" frameborder="0"></iframe>

如何从结构编号列中获取数据并对其进行排序?

1 个答案:

答案 0 :(得分:0)

包括tablesorter:http://tablesorter.com/docs/

HTML

 <table id="mytable" class="tablesorter">
      <thead>
        <tr>
          <th>Last Name</th>
          <th>First Name</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td originalid="pivot__R1" class="p-dim-member" fidx="1" val="109">
            <div class="wrapper">
              <div class="p-head-content"><span>109</span>
              </div>
            </div>
          </td>
          <td>data3</td>
        </tr>

        <tr>
          <td originalid="pivot__R4" class="p-dim-member" fidx="1" val="11" style="height: 24px;">
            <div class="wrapper">
              <div class="p-head-content"><span>11</span>
              </div>
            </div>
          </td>
          <td>data5</td>
        </tr>
      </tbody>
    </table>

JS:

$("#mytable").tablesorter();

https://jsfiddle.net/5a3j7ek1/1/