本文实例为大家分享了jquery排序插件tablesorter的使用方法,供大家参考,具体内容如下
1.先引两个js
<script type="text/javascript" src="../js/jquery-1.3.2.min.js"></script> <script type="text/javascript" src="../js/jquery.tablesorter.min.js"></script>
注意:表格要用thead/th和tbody。如:
<table id="mytable"> <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> </tbody> <table>
3.调用排序js代码
<script type="text/javascript"> $(document).ready(function() { $("#mytable").tablesorter(); }); </script>
再回到页面点击第一行就可以进行排序了.
ps:
1.一定要引jquery包,所有jq插件都是基于jquery包的
2.如果想指定哪一栏不排序这样写
$("#mytable").tablesorter({headers:{5:{sorter:false}}});
第5列的sorter为false就ok了
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。
如对本文有疑问, 点击进行留言回复!!
offset、client、scroll (width,height、left,top、X,Y)
网友评论