jQuery Mobile - 过滤器显示
描述
过滤器显示功能可让您使用本地数据轻松构建简单的自动完成功能。
当用于搜索的文本字段为空时,您可以使用 data-filter-reveal = "true" 属性自动隐藏所有列表项。
示例
以下示例演示了在 jQuery Mobile 中使用过滤器显示。
<!DOCTYPE html>
<html>
<head>
<title>Filter Reveal</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>
<ul data-role = "listview" data-filter = "true" data-filter-reveal = "true"
data-filter-placeholder = "Search your products..." data-inset = "true">
<li><a href = "#">Electronics</a></li>
<li><a href = "#">Clothing</a></li>
<li><a href = "#">Home and furnitures</a></li>
<li><a href = "#">Media and books</a></li>
<li><a href = "#">Babies and kids</a></li>
<li><a href = "#">Mobile and tablets</a></li>
</ul>
</body>
</html>
输出
让我们执行以下步骤,看看上面的代码是如何工作的 −
将上述 html 代码保存为服务器根文件夹中的 filterable_reveal.html 文件。
将此 HTML 文件打开为 http://localhost/filterable_reveal.html,将显示以下输出。

