我正在尝试使用 JPList 对多个元素进行排序。目前 JPList 搜索像“AND”(例如对具有标签、html、php 和 jQuery 的元素进行排序)但我想过滤包含这些标签的所有元素(例如对包含 html、php 的所有元素进行排序或 jQuery)。是否有启用此功能的选项?
或者有人知道在没有 JPlist 的情况下实现这一目标的方法吗?
下面是代码(注意:这是JPlist的默认代码。您可以在这里查看:https://www.jplist.org/documentation/controls/checkbox-path-filter):
<h1><a href="https://jplist.org/documentation/controls/checkbox-path-filter">jPList Checkbox Path Filter Control</a></h1>
<div class="box">
<!-- checkbox path filter control -->
<label>
<input
type="checkbox"
data-jplist-control="checkbox-path-filter"
data-path=".title"
data-group="data-group-1"
name="name1"
checked />
Filter by Title
</label>
<!-- checkbox path filter control -->
<label>
<input
type="checkbox"
data-jplist-control="checkbox-path-filter"
data-path=".views"
data-group="data-group-1"
name="name2" />
Filter by Views
</label>
<!-- checkbox path filter control -->
<label>
<input
type="checkbox"
data-jplist-control="checkbox-path-filter"
data-path=".likes"
data-group="data-group-1"
name="name3" />
Filter by Likes
</label>
</div>
<!-- content to filter -->
<div data-jplist-group="data-group-1">
<!-- item -->
<div data-jplist-item>
<div class="views likes">Views value + Likes value</div>
</div>
<!-- item -->
<div data-jplist-item>
<div class="title">Title value</div>
</div>
<!-- item -->
<div data-jplist-item>
<div class="views title">Views value + title value</div>
</div>
<!-- item -->
<div data-jplist-item>
<div class="title likes">Title value + likes value</div>
</div>
<!-- item -->
<div data-jplist-item>
<div class="likes">Likes value</div>
</div>
<!-- item -->
<div data-jplist-item>
<div class="title">Title value</div>
</div>
<!-- item -->
<div data-jplist-item>
<div class="title">Title value</div>
</div>
<!-- item -->
<div data-jplist-item>
<div class="title">Title value</div>
</div>
<!-- item -->
<div data-jplist-item>
<div class="title">Title value</div>
</div>
<!-- item -->
<div data-jplist-item>
<div class="likes">Likes value</div>
</div>
<!-- item -->
<div data-jplist-item>
<div class="title">Title value</div>
</div>
<!-- item -->
<div data-jplist-item>
<div class="title">Title value</div>
</div>
<!-- item -->
<div data-jplist-item>
<div class="title">Title value</div>
</div>
<!-- item -->
<div data-jplist-item>
<div class="title">Title value</div>
</div>
<!-- item -->
<div data-jplist-item>
<div class="views title">Views value + title value</div>
</div>
<!-- item -->
<div data-jplist-item>
<div class="likes">Likes value</div>
</div>
<!-- item -->
<div data-jplist-item>
<div class="views">Views value</div>
</div>
<!-- item -->
<div data-jplist-item>
<div class="likes">Likes value</div>
</div>
<!-- item -->
<div data-jplist-item>
<div class="views">Views value</div>
</div>
<!-- item -->
<div data-jplist-item>
<div class="views likes">Views value + likes value</div>
</div>
</div>
<style>
html, body{
background: #efefef;
box-sizing: border-box;
padding: 10px;
}
h1{
text-align: center;
margin: 0 0 10px 0;
padding: 0;
font-size: 22px;
color: #212529;
}
a{
color: #212529;
}
a:hover{
text-decoration: none;
}
[data-jplist-group]{
display: flex;
font-size: 16px;
flex-wrap: nowrap;
flex-direction: column;
align-items: center;
width: 100%;
box-sizing: border-box;
}
[data-jplist-item]{
border-bottom: 1px dotted #ccc;
width: 100%;
text-align: center;
padding: 10px 0;
box-sizing: border-box;
}
.box{
display: flex;
justify-content: center;
margin: 20px 0;
}
label{
display: inline-block;
margin: 0 10px;
}
</style>
<script>
jplist.init();
</script>
这是来自 JPlist 的工作代码笔演示:https://codepen.io/1rosehip/pen/RyYrJG
在复选框组的所有组中添加属性data-or="example"
。
例如:
<div class="box">
<!-- checkbox path filter control -->
<label>
<input
type="checkbox"
data-jplist-control="checkbox-path-filter"
data-path=".title"
data-group="data-group-1"
name="name1"
data-or="example"
checked />
Filter by Title
</label>
<!-- checkbox path filter control -->
<label>
<input
type="checkbox"
data-jplist-control="checkbox-path-filter"
data-path=".views"
data-group="data-group-1"
name="name2"
data-or="example"/>
Filter by Views
</label>
<!-- checkbox path filter control -->
<label>
<input
type="checkbox"
data-jplist-control="checkbox-path-filter"
data-path=".likes"
data-group="data-group-1"
name="name3"
data-or="example"/>
Filter by Likes
</label>
</div>
它对我有用!
我是一名优秀的程序员,十分优秀!