我正在尝试使用表格排序器对我的表格进行排序,但它不起作用
<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>
样式似乎有效,但没有排序。
这就是表格现在的样子。
最佳答案
您忘记关闭脚本标签 </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/