網路城邦
RSS Feed Link 部落格聯播

文章數:13
讓網頁表格能主動排序 TableSorter
不分類不分類 2024/07/05 02:39:44



HTML


您還可以在初始化表時傳入配置選項。這告知 tablesorter 按升序對第一列和第二列進行排序。

文章出處:NetYea 新竹網頁設計

  1. <table id="myTable" class="tablesorter">
  2.   <thead>
  3.     <tr>
  4.       <th>Last Name</th>
  5.       <th>First Name</th>
  6.       <th>Email</th>
  7.       <th>Due</th>
  8.       <th>Web Site</th>
  9.     </tr>
  10.   </thead>
  11.   <tbody>
  12.     <tr>
  13.       <td>Smith</td>
  14.       <td>John</td>
  15.       <td>jsmith@gmail.com</td>
  16.       <td>$50.00</td>
  17.       <td>http://www.jsmith.com</td>
  18.     </tr>
  19.     <tr>
  20.       <td>Bach</td>
  21.       <td>Frank</td>
  22.       <td>fbach@yahoo.com</td>
  23.       <td>$50.00</td>
  24.       <td>http://www.frank.com</td>
  25.     </tr>
  26.     <tr>
  27.       <td>Doe</td>
  28.       <td>Jason</td>
  29.       <td>jdoe@hotmail.com</td>
  30.       <td>$100.00</td>
  31.       <td>http://www.jdoe.com</td>
  32.     </tr>
  33.     <tr>
  34.       <td>Conway</td>
  35.       <td>Tim</td>
  36.       <td>tconway@earthlink.net</td>
  37.       <td>$50.00</td>
  38.       <td>http://www.timconway.com</td>
  39.     </tr>
  40.   </tbody>
  41. </table>
複製代碼
網站架設


單擊題目,您會看到您的表格而今可以排序了!
 


  1. <!-- choose a theme file -->
  2. <link rel="stylesheet" href="/path/to/theme.default.css">
  3. <!-- load jQuery and tablesorter scripts -->
  4. <script type="text/javascript" src="/path/to/jquery-latest.js"></script>
  5. <script type="text/javascript" src="/path/to/jquery.tablesorter.js"></script>
  6.  
  7. <!-- tablesorter widgets (optional) -->
  8. <script type="text/javascript" src="/path/to/jquery.tablesorter.widgets.js"></script>
複製代碼
  1. <script>
  2. $(function() {
  3.   $("#myTable").tablesorter({ sortList: [[0,0], [1,0]] });
  4. });
  5. </script>
複製代碼
  1. <script>
  2. $(function() {
  3.   $("#myTable").tablesorter();
  4. });
  5. </script>
複製代碼



tablesorter 在加載文檔時對表格進行排序:
插足script

 

1.png

1、TableSorter 介紹

在所有 jQuery 表格排序外掛裡面,TableSorter 算是使用率最高的,並且擴充功能相當多(但紛歧定用得到),是以本篇保舉這個東西。網站架設

1. 官網說明

https://mottie.github.io/tablesorter/docs/

下載檔案後找到這幾個檔案

 

最新創作
讓網頁表格能主動排序 TableSorter
2024/07/05 02:39:44 |瀏覽 32 回應 0 推薦 0 引用 0
【Python 爬蟲】抓取 Google 搜尋成效的貫串連接 網站架設
2024/05/29 14:31:11 |瀏覽 105 回應 0 推薦 0 引用 0
bootstrap 在小銀幕下若何把導覽列下移不致擋住LOGO
2024/05/11 21:40:40 |瀏覽 33 回應 0 推薦 0 引用 0
SEO 網頁優化 若何用 Google Search Console 網址審查功能
2024/04/24 08:21:32 |瀏覽 38 回應 0 推薦 0 引用 0
CPanel 就事器用transfer Tool對拷主機, 有些網站顯示error 500 網站架設
2024/04/03 04:14:43 |瀏覽 38 回應 0 推薦 0 引用 0