tablesorter下载地址:http://tablesorter.com/
先简单介绍下tablesorter:
tablesorter is a jQuery plugin for turning a standard HTML table with THEAD and TBODY tags into a sortable table without page refreshes. tablesorter can successfully parse and sort many types of data including linked data in a cell. It has many useful features including:
- Multi-column sorting
- Parsers for sorting text, URIs, integers, currency, floats, IP addresses, dates (ISO, long and short formats), time. Add your own easily
- Support for ROWSPAN and COLSPAN on TH elements
- Support secondary "hidden" sorting (e.g., maintain alphabetical sort when sorting on other criteria)
- Extensibility via widget system
- Cross-browser: IE 6.0+, FF 2+, Safari 2.0+, Opera 9.0+
- Small code size
下载的tablesorter有很多例子,如果只是想看看它的排序功能,看例子就很好,而且也能很快画出简单的葫芦来.
可能是我以前没有做过表格排序的东西,第一次做遇到了很多的问题.
你要用tablesorter排序,基本的表格格式如下:
<table><thead><tr><th></th></thead><tbody><tr><td></td></tr></tbody></table>
<thead>和<tbody>是必须要有的.
表头和表的内容可以从其他数据源获得,但是
<thead><tr><th></th></thead>必须写在htlm代码里 ,用js动态生成都不行,里面的内容能从数据源获得.
这是我学习tablesorter的经验.