很抱歉提出这个愚蠢的问题,但我已经挣扎了几个小时但没有成功。 我的样本表没有被排序。两个 .js 文件都位于与 .shtml 文件本身相同的目录中。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us">
<head>
<script type="text/javascript" src="jquery-latest.js"></script>
<script type="text/javascript" src="jquery.tablesorter.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
$("#myTable").tablesorter();
}
);
</script>
</head>
<body>
<table id="myTable" class="tablesorter">
<thead>
<tr>
<th>Test1</th>
<th>Test2</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>1622</td>
</tr>
<tr>
<td>2</td>
<td>2634</td>
</tr>
</tbody>
</table>
</body>
</html>
最佳答案
也许你有 jquery 和 tablesorter 的错误副本?使用从各自站点链接的 jquery 和 tablesorter 的实际版本,它似乎对我来说工作得很好。
http://code.jquery.com/jquery-1.9.1.js
http://mottie.github.com/tablesorter/js/jquery.tablesorter.js
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us">
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" src="http://mottie.github.com/tablesorter/js/jquery.tablesorter.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
$("#myTable").tablesorter();
}
);
</script>
</head>
<body>
<table id="myTable" class="tablesorter">
<thead>
<tr>
<th>Test1</th>
<th>Test2</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>1622</td>
</tr>
<tr>
<td>2</td>
<td>2634</td>
</tr>
</tbody>
</table>
</body>
关于jquery - 表排序器不排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15594251/