jQuery html表格排序外掛程式tablesorter使用方法詳解,jquerytablesorter

來源:互聯網
上載者:User

jQuery html表格排序外掛程式tablesorter使用方法詳解,jquerytablesorter

tablesort是一款很好用的jQuery表格排序外掛程式。 支援多種資料類型排序,會自動識別表格內容資料類型,使用也非常方便。
使用jQuery tablesort實現html表格方法:

1. 下載jQuery和tablesort指令碼,並在html中引用該指令檔:

<script type="text/javascript" src="../jquery-latest.js"></script><script type="text/javascript" src="../jquery.tablesorter.js"></script>

2. 格式化需要排序的html表格:

a. 給需要排序的表格指定CCS類:class="sort-table"
b. 使用thead和tbody標籤來標記表格頭和表格本文
c. 在表格頭thead中需要使用th標籤定義表頭
格式化好的html表格如下所示:

<table border=1 width="800px" class="sort-table"><thead> <tr> <th>Date</th> <th>Usage</th> <th>Cost</th> <th>Remain</th> </tr></thead><tbody> <tr> <td>2008-3-25</td> <td>book place @dhgu</td> <td>-40</td> <td>-40</td> </tr> <tr> <td>2008-4-1</td> <td>book place @dhgu</td> <td>-40</td> <td>-80</td> </tr></tbody></table>

3. 添加jQuery代碼,啟用html表格排序:
在body中對在第二步中指定的排序表格css類調用tablesorter()函數:

<body><script type="text/javascript"> $(document).ready(function() { $(".sort-table").tablesorter();  });</script>

通過上面的3步,jQuery tablesort就可以實現對html表格的排序。

下載jQuery外掛程式tablesort

以上就是本文的全部內容,希望對大家的學習有所協助,也希望大家多多支援幫客之家。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.