2015-12-14 60 views
-2

我有數據顯示在html表中。我需要梳理只有一列 https://jsfiddle.net/5a3j7ek1/如何在html表中對列進行排序

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

請問如何從結構數列中的數據和排序呢?

+0

您要根據客怎麼排序?第一列?第二?你想使用JavaScript來做到這一點? – chapinkapa

+0

你可以嘗試看看[jQuery表排序](http://stackoverflow.com/questions/3160277/jquery-table-sort) – gaetanoM

回答

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/