I have the below code for a simple checkbox filter. It works well if all conditions are met with the checkboxes, i.e. Monday or Tuesday are checked. But checking both Monday and Tuesday gives no results. I would like it to show results that have a Monday or a Tuesday but can’t adapt what i have. Any help massively appreciated!
$('form#filter').on('change', function () {
var filterList = [];
$("form#filter .checkDays input:checked").each(function () {
var dataDays = $(this).val();
filterList.push(dataDays);
});
$("form#filter .checkTime input:checked").each(function () {
var dataTime = $(this).val();
filterList.push(dataTime);
});
if (filterList.length == 0) {
jQuery('.card').removeClass('is-hidden');
jQuery('.card').fadeIn();
} else {
jQuery('.card').filter(function () {
const isVisible = ['data-combined'].some(attr => {
const attrValue = jQuery(this).attr(attr);
if (!attrValue) {
return;
}
const offerings = attrValue.split(',');
return filterList.every(offering => offerings.indexOf(offering) > -1);
});
if (isVisible) {
jQuery(this).fadeIn('slow');
} else {
jQuery(this).hide();
}
});
}
});