【发布时间】:2010-12-27 15:16:38
【问题描述】:
我也尝试使用 tablesorter 插件 (http://tablesorter.com) 将数据附加到表中 我使用以下代码:
<table id="sortme" border="1" style="width: 200px;">
<thead>
<tr>
<th>first name</th>
<th>last name</th>
<th>age</th>
</tr>
</thead>
<tbody>
<tr>
<td>will</td>
<td>smith</td>
<td>1</td>
</tr>
...................
</tbody>
</table>
<a href="#" id="test">Click me!</a>
还有:
$(document).ready(function() {
var i = 5;
$("#sortme").tablesorter({
sortList: [[2,0]]
});
$("#test").click(function() {
$("#sortme tbody").append('<tr><td>NEW</td><td>NEW</td><td>'+(i++)+'</td></tr>');
$("#sortme").trigger("update");
var s = [[2,0]];
$("#sortme").trigger("sorton",[s]);
return false;
});
});
问题是附加的行停留在顶部,为什么? 参见示例:http://jsfiddle.net/jmU3Z/8/
【问题讨论】:
标签: javascript jquery tablesorter