- jQuery Mobile 教程
- jQuery Mobile - 主頁
- jQuery Mobile - 概述
- jQuery Mobile - 設定
- jQuery Mobile - 網頁
- jQuery Mobile - 圖示
- jQuery Mobile - 過渡
- jQuery Mobile - 佈局
- jQuery Mobile - 小元件
- jQuery Mobile - 事件
- jQuery Mobile - 表單
- jQuery Mobile - 主題
- jQuery Mobile - CSS 類
- jQuery Mobile - 資料屬性
- jQuery Mobile 有用資源
- jQuery Mobile - 面試問題
- jQuery Mobile - 快速指南
- jQuery Mobile - 有用資源
- jQuery Mobile - 討論
jQuery Mobile - 表格篩選器
描述
要生成表格篩選器,請在要為其生成篩選器的表格元素上將 data-filter 屬性設定為 true。
示例
以下示例演示瞭如何使用 jQuery Mobile 中的 table filter(表格篩選器)。
<!DOCTYPE html>
<html>
<head>
<title>Filterable Table</title>
<meta name = "viewport" content = "width = device-width, initial-scale = 1">
<link rel = "stylesheet" href = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<script src = "https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
</head>
<body>
<form>
<input id = "filterTable-input" data-type = "search">
</form>
<table data-role = "table" id = "movie-table" data-filter = "true"
data-input = "#filterTable-input" class = "ui-responsive">
<thead>
<tr>
<th data-priority = "1">Rank</th>
<th data-priority = "persist">Country</th>
<th data-priority = "2">Area sq.km.</th>
<th data-priority = "3">Capital</th>
<th data-priority = "4">Currency</th>
</tr>
</thead>
<tbody>
<tr>
<th>1</th>
<td>Russia</td>
<td>17,075,200</td>
<td>Moscow</td>
<td>Russian ruble</td>
</tr>
<tr>
<th>2</th>
<td>Canada</td>
<td>9,984,670</td>
<td>Ottawa</td>
<td>Canadian dollar</td>
</tr>
<tr>
<th>3</th>
<td>United States of America</td>
<td>9,826,630</td>
<td>Washington, D.C.</td>
<td>US Dollar</td>
</tr>
<tr>
<th>4</th>
<td>China</td>
<td>9,596,960</td>
<td>Beijing</td>
<td>Renminbi</td>
</tr>
<tr>
<th>5</th>
<td>Brazil</td>
<td>8,511,965</td>
<td>Brasilia</td>
<td>Brazilian real</td>
</tr>
<tr>
<th>6</th>
<td>Australia</td>
<td>7,686,850</td>
<td>Canberra</td>
<td>Australian dollar</td>
</tr>
<tr>
<th>7</th>
<td>India</td>
<td>3,287,590</td>
<td>New Delhi</td>
<td>Indian Rupee</td>
</tr>
</tbody>
</table>
</body>
</html>
輸出
讓我們執行以下步驟,瞭解以上程式碼是如何工作的 -
將上述 HTML 程式碼作為 filterable_table.html 檔案儲存在伺服器根資料夾中。
將此 HTML 檔案作為 https:///filterable_table.html 開啟,將顯示以下輸出。
jquery_mobile_widgets.htm
廣告