我是Jquery的新手,我正在尝试使用Jquery Tablesorter插件,我已经在一个简单的html文件中对它进行了测试,如下所示,但它不工作。我在浏览器中看到的只是一个没有排序的普通表格,没有可点击的标题,它看起来不像我在Jquery Tablesorter主页上看到的那样。我不知道我的html出了什么问题。我已经将两个jquery文件和这个html文件放在同一个文件夹中。敬请指教!
<html>
<head>
<script type="text/javascript" src="jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="jquery.tablesorter.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
$("#myTable").tablesorter( {sortList: [[0,0], [1,0]]} );
}
);
</script>
</head>
<body>
<table id="myTable" class="tablesorter">
<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>发布于 2013-03-30 13:23:30
这是有效的小提琴链接。您忘记添加我在jsfiddle的外部资源中添加的tablesorter js和tablesorter css。你可以去查一下。
http://jsfiddle.net/BKgue/2/
发布于 2016-10-05 10:39:35
注意<tr>内部的<th>,而不是<td>,这是阻止它为我工作的原因。
<thead>
<tr>
<th>column 1</th>
<tr>
</thead>此外,css也不是表排序工作所必需的。如果您希望保持自己的格式,但又希望显示小箭头,则只需以下代码。并将tablesorter提供的3箭头gif复制粘贴到与css文件相同的文件夹中。或者你自己的箭头gif,如果你想。
table.tablesorter thead tr .header {
background-image: url(bg.gif);
background-repeat: no-repeat;
background-position: center right;
cursor: pointer;
}
table.tablesorter thead tr .headerSortUp {
background-image: url(asc.gif);
}
table.tablesorter thead tr .headerSortDown {
background-image: url(desc.gif);
}https://stackoverflow.com/questions/15715127
复制相似问题