我想在jsp中對錶進行排序。我用了一個名爲tableSorter的jquery插件對我的表進行排序,但我沒有任何運氣。這是我的代碼。我不知道我錯過了什麼。我正在從MYSQL數據庫填充此表。在jsp中使用jquery插件對錶進行排序
這是我用來排序jsp中表格的表格排序函數。
<script type="text/javascript" src="js/jquery-ui-min.js"></script>
<script type="text/javascript" src="js/jquery.tinysort.min.js"></script>
var aAsc = [];
function sortTable(nr) {
aAsc[nr] = aAsc[nr]=='asc'?'desc':'asc';
$('#records>tbody>tr').tsort('td:eq('+nr+')[abbr]',{order:aAsc[nr]});
}
<table ID="records" class="results" border="1" cellspacing="0">
<thead>
<tr>
<th><a href="javascript:sortTable(0)" style=" color: #ffffff; text-decoration: underline; ">ID</a></th>
<th>Name</th>
<th>Date</th>
</tr>
</thead>
<logic:notEmpty property="results" name="finalResults" scope="page">
<logic:iterate id="i" indexId="count" property="results" name="finalResults" scope="page">
<%-- Logic for formatting the data from DB goes here--%>
</logic:iterate>
</logic:notEmpty>
我在這裏使用href來對數據進行排序。但是當我點擊它時,href不會做任何事情。我錯過了什麼?
表中沒有上下箭頭(如[docs demo](http://mottie.github.io/tablesorter/docs/index.html#Demo))或什麼? – Regent 2014-10-07 16:20:54
我使用href對數據進行排序。點擊它後,該列會進行排序。我想排序個別列而不是整個表本身。 – user1041431 2014-10-07 18:27:33