我正在使用list.js搜索/排序无序列表,这是很好的。但是,我想添加对包含数值的几个列的搜索。搜索时,它将返回所有等于或大于搜索值的项。
示例
值: 24,65,95,104
搜索: 80
返回: 95,104
我怎样才能做到这一点?提前谢谢。我还发现了这段代码,它可能会有帮助:
$('.filter-2').on('click', function() {
userList.filter(function(item) {
var born = parseInt(item.values().born);
console.log(born);
if (born < 1986) {
return true;
} else {
return false;
}
});
});发布于 2018-02-03 17:55:41
在普通javascript中:
var array = [24,65,95,104];
console.log(arr.filter(function (num){
return number > 80;
}));在list.js中,它非常类似于滤波法
itemsInList ={ id: 1,name:"Jonny“},{ id: 2,name:"Gustaf”},{ id: 3,name:"Jonas“};listObj.filter(函数(项){返回item.values().id > 1;});/仅id >1的项显示在列表中。
https://stackoverflow.com/questions/48600053
复制相似问题