我正在尝试创建一个分面搜索,以便我的列表项可以缩小,但我的逻辑肯定是关闭的。当我在不同的过滤器上选中一个复选框时,我需要减少结果,但我会添加它们。
我已经看过要使用的插件,但我能找到的所有内容都使用与bootstrap冲突的旧jQuery库。
我是jQuery的新手,所以请善待。
目前,我正在使用:
jQuery(document).ready(function(){
$('input').click(function() {
$(this).attr("disabled", true);
var someObj = {};
someObj.idsGranted = [];
someObj.idsDenied = [];
$("input:checkbox").each(function() {
if ($(this).is(":checked")) {
someObj.idsGranted.push($(this).attr("id"));
jQuery.each( someObj.idsGranted, function() {
jQuery('li.'+this).addClass('granted');
});
} else {
someObj.idsDenied.push($(this).attr("id"));
jQuery.each( someObj.idsDenied, function() {
jQuery('li.'+this).addClass('denied');
});
}
});
$count = $("[type='checkbox']:checked").length;
if ($count == '0') {
jQuery('li.jobS').removeClass('granted');
jQuery('li.jobS').removeClass('denied');
};
$('.reset').click(function() {
$('input').attr('disabled', false);
$('input').attr('checked', false);
jQuery('li.jobS').removeClass('granted');
jQuery('li.jobS').removeClass('denied');
})
});
});
我的努力可以在这里看到: http://79.170.40.40/newarthur.co.uk/find-a-job/