jquery - 表排序器不排序

标签 jquery tablesorter

很抱歉提出这个愚蠢的问题,但我已经挣扎了几个小时但没有成功。 我的样本表没有被排序。两个 .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/

相关文章:

javascript - 用于将 Tablesorter 列的过滤器从选择切换到输入的 jQuery 按钮,反之亦然

javascript - JQuery .val 不工作

jquery - 使对象在 div 换行的约束范围内移动?

jquery如何检索p标签中的字符数?

javascript - jQuery Tablesorter 添加 alt 属性

jquery - 我如何使用 tablesorter 处理 4 行组

jquery - SlideToggle() 可以检测 SlideUp 或 SlideDown 吗?

javascript - 单击按钮滚动到特定的 div

javascript - 使用tablesorter.js 对表中的ajax 数据进行排序

javascript - Tablesorter,对简单数字进行排序