Tablesorter demo
All options included, as well as the uitheme widget
HTML
<link rel="stylesheet" href="https://mottie.github.io/tablesorter/css/theme.blue.css">
<link rel="stylesheet" href="https://mottie.github.io/tablesorter/css/theme.dark.css">
<link rel="stylesheet" href="https://mottie.github.io/tablesorter/css/theme.default.css">
<link rel="stylesheet" href="https://mottie.github.io/tablesorter/css/theme.dropbox.css">
<link rel="stylesheet" href="https://mottie.github.io/tablesorter/css/theme.green.css">
<link rel="stylesheet" href="https://mottie.github.io/tablesorter/css/theme.grey.css">
<link rel="stylesheet" href="https://mottie.github.io/tablesorter/css/theme.ice.css">
<link rel="stylesheet" href="https://mottie.github.io/tablesorter/css/theme.black-ice.css">
<link rel="stylesheet" href="https://mottie.github.io/tablesorter/css/theme.bootstrap.css">
<link rel="stylesheet" href="https://mottie.github.io/tablesorter/addons/pager/jquery.tablesorter.pager.css">
<script src="https://mottie.github.io/tablesorter/js/jquery.tablesorter.js"></script>
<script src="https://mottie.github.io/tablesorter/js/jquery.tablesorter.widgets.js"></script>
<script src="https://mottie.github.io/tablesorter/addons/pager/jquery.tablesorter.pager.js"></script>
<link rel="stylesheet" href="https://mottie.github.io/tablesorter/css/theme.jui.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/cupertino/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.js"></script>
<table id="tablesorter-demo" class="tablesorter-blue">
<thead>
<tr>
<th>Discount</th>
</tr>
</thead>
<tbody>
<tr>
<td>d20.9%%%%</td>
</tr>
<tr>
<td>c25%%%%%</td>
</tr>
<tr>
<td>b44%%%%</td>
</tr>
<tr>
<td>g66%%%%%</td>
</tr>
</tbody>
</table>
JavaScript
$.tablesorter.addParser({
id: "custom_date1", //小數點排序
is: function(s) {
return false; //關閉自動轉換
},
format: function(s) {
return parseFloat(s.replace(/[^0-9\.]+/g,"")); //轉換為數字
},
type: "numeric" //應用數字類排序
});
var sort1 = 0;
var headersObj = {};
headersObj[sort1] = { sorter: 'custom_date1' };
$("table").tablesorter({
theme : 'blue',
headers: headersObj
});