首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >JQuery TableSort不适用于JQuery floatThead

JQuery TableSort不适用于JQuery floatThead
EN

Stack Overflow用户
提问于 2018-10-19 11:36:25
回答 1查看 254关注 0票数 1

我有一个来自tablesorter@github的示例表

单击表标题对表进行排序。当我添加在本例中注释的这一行$('table#myTable').floatThead();时,它就停止工作了。

知道问题是什么吗?怎么解决?

代码语言:javascript
复制
<html lang="en">
 <head>
   <title>JQuery table sorter with JQuery floatThead MCVE</title>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
   <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
   <script src="https://rawgit.com/christianbach/tablesorter/master/jquery.tablesorter.min.js"></script>
   <script src="https://cdnjs.cloudflare.com/ajax/libs/floatthead/2.1.2/jquery.floatThead.min.js"></script>
 </head>
 <body>
  <table id="myTable" class="tablesorter" border=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>$40.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>$51.00</td> 
   <td>http://www.timconway.com</td></tr> 
  </tbody> 
  </table>   

  <script type="text/javascript">
   //$('table#myTable').floatThead();
   $(document).ready(function() { $("#myTable").tablesorter(); } 
   );
  </script>
 </body>
</html>

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-10-19 11:56:59

我偶然发现了一个非常简单的解决方案:订单很重要!只需在调用了函数$('table#myTable').floatThead(); 之后添加tablesorter()

代码语言:javascript
复制
<html lang="en">
 <head>
   <title>JQuery table sorter with JQuery floatThead MCVE</title>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
   <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
   <script src="https://rawgit.com/christianbach/tablesorter/master/jquery.tablesorter.min.js"></script>
   <script src="https://cdnjs.cloudflare.com/ajax/libs/floatthead/2.1.2/jquery.floatThead.min.js"></script>
 </head>
 <body>
  <table id="myTable" class="tablesorter" border=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>$40.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>$51.00</td> 
   <td>http://www.timconway.com</td></tr> 
  </tbody> 
  </table>   

  <script type="text/javascript">
   $(document).ready(function() { $("#myTable").tablesorter(); $('table#myTable').floatThead(); } 
   );
  </script>
 </body>
</html>

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52891595

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档