Demo
First Name |
Last Name |
Age |
Total |
Discount |
Date |
Peter |
Parker |
28 |
$9.99 |
20% |
Jul 6, 2006 8:14 AM |
John |
Hood |
33 |
$19.99 |
25% |
Dec 10, 2002 5:14 AM |
Clark |
Kent |
18 |
$15.89 |
44% |
Jan 12, 2003 11:14 AM |
Bruce |
Almighty |
45 |
$153.19 |
44% |
Jan 18, 2001 9:12 AM |
Bruce |
Evans |
22 |
$13.19 |
11% |
Jan 18, 2007 9:12 AM |
Javascript
$(document).ready(function() {
// extend the default setting to always include the zebra widget.
$.tablesorter.defaults.widgets = ['zebra'];
// extend the default setting to always sort on the first column
$.tablesorter.defaults.sortList = [[0,0]];
// call the tablesorter plugin
$("table").tablesorter();
});
HTML
<table cellspacing="1" class="tablesorter">
<thead>>
<tr>
<th>first name</th>
<th>last name</th>
<th>age</th>
<th>total</th>
<th>discount</th>
<th>date</th>
</tr>
</thead>
<tbody>
<tr>
<td>peter</td>
<td>parker</td>
<td>28</td>
<td>$9.99</td>
<td>20%</td>
<td>jul 6, 2006 8:14 am</td>
</tr>
<tr>
<td>john</td>
<td>hood</td>
<td>33</td>
<td>$19.99</td>
<td>25%</td>
<td>dec 10, 2002 5:14 am</td>
</tr>
<tr>
<td>clark</td>
<td>kent</td>
<td>18</td>
<td>$15.89</td>
<td>44%</td>
<td>jan 12, 2003 11:14 am</td>
</tr>
<tr>
<td>bruce</td>
<td>almighty</td>
<td>45</td>
<td>$153.19</td>
<td>44%</td>
<td>jan 18, 2001 9:12 am</td>
</tr>
<tr>
<td>bruce</td>
<td>evans</td>
<td>22</td>
<td>$13.19</td>
<td>11%</td>
<td>jan 18, 2007 9:12 am</td>
</tr>
</tbody>
</table>