Jquery.tablesorter不工作

时间:2014-02-25 10:01:06

标签: jquery

我想点击向上箭头按升序排序名称,点击向下箭头按降序排序。我还下载了_jquery.troubleshooter.zip.But我不知道如何使用它下面的文件。谁能打电话给我怎么办?

CSS:

table td {
      font-family:Verdana, Geneva, sans-serif;
      font-size:15px;
      color:#280000;
      background-color:#92C9C9;
}
table th {
      background-color:#4E9C9C;
      font-size:20px;   
}
input {
      background-color:#4E9C9C;
      border-color:#87C2C2;
      font-family:Verdana, Geneva, sans-serif;
      font-size:14px;
}

脚本:

<script src="jquery-1.11.0.min.js"></script>
<script src="jquery.tablesorter.js"></script>
<script src="jquery-latest.js"></script>
<script>
$(document).ready(function() 
{ 
    $("#myTable").tablesorter( {sortList: [[0,0], [1,0]]} ); 
} 
);
</script>

HTML:

<table id="myTable" class="tablesorter" cellspacing="0px" cellpadding="5px" border="5px" bordercolor="#346969"  style="margin-top:30px">              
   <tr>
      <thead><th>Name
      <th>Roll No
      <th>Phone no
      <th>Address
      <th>Course
      <th>Branch
      <th>Year
      <th>Delete</thead>
   <tbody><tr id="r1">
      <td>Abc
      <td>10/cs117
      <td>9837556645
      <td>Blb
      <td>B.Tech
      <td>CSE
      <td>4th
      <td><input type="button" value="Delete" id="b1">
   <tr id="r2">
      <td>Bcd
      <td>10/EC47
      <td>9877665543
      <td>Sector-7
      <td>B.Tech
      <td>ECE
      <td>3rd
      <td><input id="b2" type="button" value="Delete">
   <tr id="r3">
      <td>Cde
      <td>10/IT12
      <td>8543234561
      <td>Sector-10
      <td>B.Tech
      <td>ECE
      <td>4th
      <td><input id="b3" type="button" value="Delete"></tbody>
</table>

2 个答案:

答案 0 :(得分:0)

您应该使用Tablesorter.JS。您不必为此编写任何额外的代码。

希望有所帮助

答案 1 :(得分:0)

您可以使用jQuery Tablesorter插件:http://tablesorter.com/docs/