这是一个Javascript 的类库,用于table内容排序。
使用很方便,不用每次都去调用数据库。
特别适合多表查询的排序。
加上<tbody>的style.display 切换,也可以实现分页。
这里提供: sorttable.js 文件下载。
要实现以上功能只需三步即可完成:
1,Include the Javascript library, by putting a link to it in the HEAD of your page, like so:
<script src="/developer/programme/js/sorttable.js"></script>
<script src="/developer/programme/js/sorttable.js"></script>
2,Mark your table as a sortable one by giving it a class of "sortable":
<table class="sortable">
<table class="sortable">
3,Ensure that your table has an ID:
<table class="sortable" id="unique_id">
<table class="sortable" id="unique_id">
即:
1,添加JS
<SCRIPT src="/developer/programme/js/sorttable.js" type="text/javascript"></SCRIPT>
2,添加TABLE,注意的是:一定要有ID,class为"sortable"
<table class="sortable" id="mytable">
<SCRIPT src="/developer/programme/js/sorttable.js" type="text/javascript"></SCRIPT>
2,添加TABLE,注意的是:一定要有ID,class为"sortable"
<table class="sortable" id="mytable">
3,保证table里含有上面定义的ID
<table class="sortable" id="unique_id">
详细实现代码如下,请运行查看效果。(你可以先修改代码再执行)