jQuery Mobile Listview filterReveal选项
jQuery Mobile是一套基于HTML5的用户交互widget工具箱,用于各种用途,建立在jQuery之上。它旨在建立快速和响应的网站,可用于手机、标签和桌面。 jQuery Listview是一个用于创建美丽的列表的部件。它是一个简单和响应式的列表视图,用于查看无序的列表。
在这篇文章中,我们将使用jQuery Mobile Listview filterReveal选项。该filterReveal选项是用来隐藏或显示Listview的filter选项中的搜索结果列表。如果true,当搜索文本为空时,列表会隐藏起来,否则会显示完整的项目列表。对于无序列表,它也将data-filter-reveal改变为true。
语法 :我们需要将true或 false作为参数传递给 filterReveal。使用下面的语法进行初始化。
$(".items").listview({
filterReveal:true,
});
- 获取filterReveal选项。
var filterRevealOption =
$(".items").listview( "option", "filterReveal" );
- 设置filterReveal选项。
$(".items").listview( "option", "filterReveal", true );
CDN链接 。在你的项目中使用以下**jQuery Mobile的CDNs。
<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.1.min.js”></script>
<script src=”https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js”></script>
例子 :在下面的例子中,我们将选项filterReveal设置为true。
<!DOCTYPE html>
<html lang="en">
<head>
<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.1.min.js">
</script>
<script src=
"https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js">
</script>
</head>
<body>
<h1 style="color:green">
GeeksforGeeks
</h1>
<h3>jQuery Mobile Listview filterReveal Option</h3>
<ul class="items" data-filter-reveal="true">
<li>
<a href=
"https://www.geeksforgeeks.org/data-structures"
target="_blank">
Data Structures
</a>
</li>
<li>
<a href=
"https://practice.geeksforgeeks.org/courses/complete-interview-preparation"
target="_blank">
Interview preparation
</a>
</li>
<li>
<a href="https://www.geeksforgeeks.org/java"
target="_blank">
Java Programming
</a>
</li>
</ul>
<script>
$(".items").listview({
filter: true,
filterReveal: true,
});
</script>
</body>
</html>
输出:

极客教程