I am working on a filter system for a website whereby products can be filtered to show only those that are selected. I have the following working model:
$(function() {
var selectedClass = "";
$(".category").click(function(){
selectedClass = $(this).attr("data-rel");
$(".products").fadeTo(100, 0.1);
$(".products .all").not("."+selectedClass).fadeOut().removeClass('show');
setTimeout(function() {
$("."+selectedClass).fadeIn().addClass('show');
$(".products").fadeTo(300, 1);
}, 300);
});
});
Items are filtered using a list and the data-rel selects only those items that have the class assigned to them. This all works fine but I now need the items to be filtered by more than one selection. I want a user to be able to select from one list two options but I only want the options to show that fit both criteria.
For example, if I have items such as 'red' 'green' and 'blue' as well as 'square' 'circle' and 'triangle', I want a user to be able to select 'red' and 'square' and for the results to show only the items that match both of those selections as opposed to all items that match either.
Any help would be much appreciated.
. categorya button?