一个Javascript 的类库,用于table内容排序。使用很方便,不用每次都去调用数据库了。
特别适合多表查询的排序。加上<tbody>的style.display 切换,也可以实现分页。
点击标题排序
| Name | Salary | Extension | Start date↓ |
|---|---|---|---|
| Shakespeare, Bill | $122000.00 | 3211 | 12/11/1961 |
| Turvey, Kevin | $191200.00 | 2342 | 02/05/1979 |
| Fitz, Marvin | $3300 | 5554 | 22/05/1995 |
| Mbogo, Arnold | $32010.12 | 2755 | 09/08/1998 |
| Shakespeare, Hamnet | $9000 | 9005 | 01/01/2002 |
| Bloggs, Fred | $12000.00 | 1353 | 18/08/2003 |
用法:
1.添加JS JS 下载地址
<SCRIPT src="sorttable.js" type="text/javascript"></SCRIPT>
2.添加TABLE,注意的是:一定要有ID,class为"sortable"
<table class="sortable" id="mytable">
OK,可以了,简单的吧
如果觉得太单调,自己加点CSS吧,官方给出了改HEAD的CSS
/* Sortable tables */
table.sortable a.sortheader {
background-color:#eee;
color:#666666;
font-weight: bold;
text-decoration: none;
display: block;
}
table.sortable span.sortarrow {
color:black;
text-decoration: none;
}
table.sortable a.sortheader {
background-color:#eee;
color:#666666;
font-weight: bold;
text-decoration: none;
display: block;
}
table.sortable span.sortarrow {
color:black;
text-decoration: none;
}