javascript - 表排序器不工作

标签 javascript jquery html tablesorter

我正在尝试使用表格排序器对我的表格进行排序,但它不起作用

<html>
<head>
     <link rel="stylesheet" href="blueStyle.css" type="text/css" media="print, projection, screen" />
    <script src="http://tablesorter.com/jquery-latest.js" type="text/javascript"></script> 
    <script src="http://tablesorter.com/__jquery.tablesorter.min.js" type="text/javascript"></script>
    <script type="text/javascript">
    $(document).ready(function() {      
        $("#myTable").tablesorter();
    }); 
    </script>
</head>
<body>
<table id="myTable" class="tablesorter" border="0" cellpadding="0" cellspacing="1"> 
<thead> 
<tr> 
    <th>Last Name</th> 
    <th>First Name</th> 
    <th>Email</th> 
    <th>Due</th> 
    <th>Web Site</th> 
</tr> 
</thead> 
<tbody> 
<tr> 
    <td>Smith</td> 
    <td>John</td> 
    <td>jsmith@gmail.com</td> 
    <td>$50.00</td> 
    <td>http://www.jsmith.com</td> 
</tr> 
<tr> 
    <td>Bach</td> 
    <td>Frank</td> 
    <td>fbach@yahoo.com</td> 
    <td>$50.00</td> 
    <td>http://www.frank.com</td> 
</tr> 
<tr> 
    <td>Doe</td> 
    <td>Jason</td> 
    <td>jdoe@hotmail.com</td> 
    <td>$100.00</td> 
    <td>http://www.jdoe.com</td> 
</tr> 
<tr> 
    <td>Conway</td> 
    <td>Tim</td> 
    <td>tconway@earthlink.net</td> 
    <td>$50.00</td> 
    <td>http://www.timconway.com</td> 
</tr> 
</tbody> 
</table>
</body> 
 </html>   

样式似乎有效,但没有排序。

这就是表格现在的样子。 enter image description here

最佳答案

您忘记关闭脚本标签 </script> :

<script src="http://tablesorter.com/__jquery.tablesorter.min.js" type="text/javascript"/>

正确的标记:

<script src="http://tablesorter.com/__jquery.tablesorter.min.js" type="text/javascript"/></script>

我复制了你的代码,添加了</script>它对我有用。还有来自 http://tablesorter.com/jquery-latest.js 的 jquery 文件真的过时了(2008),考虑使用其他 cdn,例如//code.jquery.com/jquery-1.10.2.min.js 或 googleapis

关于javascript - 表排序器不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21498871/

相关文章:

javascript - 如何结合 Passport 和 Angular 用户界面路由

javascript - 如何在某个包装器中隐藏上一个和下一个 sibling 的内容,而不是在 jQuery 中隐藏单击的 div?

html - 半透明导航栏,后面有一个黑色 block (CSS/HTML/JS)

javascript - 如何调试 PhoneGap 应用程序中的内存使用量攀升?

javascript - 如何根据下拉选择自动点击超链接?

javascript - 为什么我的导航栏折叠切换在 react 中不起作用

javascript - 选中所有复选框

javascript - Jquery.find 返回的对象在 .data() 中表现异常

html - z-index 不适用于 li 导航栏

javascript - 点击div切换动画?