使用jquery的tablesorter插件进行表格排序

今天在学习bootstrap的时候,突然看见tablesorter这个东东了,立马百度了一下,发现了这个东东。。

             使用jquery的tablesorter插件进行表格排序

下面说一下今天我在项目中看见前辈们用的表格排序

  

tablesorter的官方网站:http://tablesorter.com/docs/

 使用方法:1.下载tablesorter http://tablesorter.com/jquery.tablesorter.zip

 2.解压文件,将jquery和jquery.tablesorter.min.js导入到项目文件中

 3.修改html:

   1).添加链接

    <script  type="text/javascript" src='/pagemedia/js/jquery.tablesorter.min.js'></script>

    <script  type="text/javascript" src='/pagemedia/js/jquery.min.js'></script>

    2).修改表格

     <table  id="myTable"  class='tablesorter'>为table添加id和class,class为tablesorter.

    (注意:table必须有thead和tbody) 

  3).添加javascript脚本:

     <script>

        $(document).ready(function(){  $("#myTable").tablesorter();  });  

    </script>

    上面的这句是网上大多地方的写法,我在项目中发现的写法是这样的:

  

原文地址:https://www.cnblogs.com/hr2014/p/3924254.html