国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

jQuery html表格排序插件tablesorter使用方法詳解

Original 2017-02-16 11:55:41 761
abstract:tablesort是一款很好用的jQuery表格排序插件。 支持多種數(shù)據(jù)類(lèi)型排序,會(huì)自動(dòng)識(shí)別表格內(nèi)容數(shù)據(jù)類(lèi)型,使用也非常方便。使用jQuery tablesort實(shí)現(xiàn)html表格方法:1. 下載jQuery和tablesort腳本,并在html中引用該腳本文件:<script type="text/javascript" src="../jq

tablesort是一款很好用的jQuery表格排序插件。 支持多種數(shù)據(jù)類(lèi)型排序,會(huì)自動(dòng)識(shí)別表格內(nèi)容數(shù)據(jù)類(lèi)型,使用也非常方便。
使用jQuery tablesort實(shí)現(xiàn)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類(lèi):class="sort-table"
b. 使用thead和tbody標(biāo)簽來(lái)標(biāo)記表格頭和表格正文
c. 在表格頭thead中需要使用th標(biāo)簽定義表頭
格式化好的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中對(duì)在第二步中指定的排序表格css類(lèi)調(diào)用tablesorter()函數(shù):

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

通過(guò)上面的3步,jQuery tablesort就可以實(shí)現(xiàn)對(duì)html表格的排序。

更多關(guān)于jQuery html表格排序插件tablesorter使用方法詳解請(qǐng)關(guān)注PHP中文網(wǎng)(m.miracleart.cn)其他文章!

Release Notes

Popular Entries