This question is an extension of jQuery Multiple Checkbox Page Filter . It's my question exactly.
I have three goals:
- I want to have a list of check boxes to filter Page Content.
- I want to return only the content that matches all of the currently checked boxes, hiding all the rest.
- If no boxes are checked, everything should show.
As previously discussed in the above question, goals A and C were accomplished with:
$('div.tags').delegate('input:checkbox', 'change', function()
{
var $lis = $('.results > li').hide();
//For each one checked
$('input:checked').each(function()
{
$lis.filter('.' + $(this).attr('rel')).show();
});
});
and goal B was accomplished with:
var selector = $('input:checked').map(function ()
{
return $(this).attr('rel');
}).get().join('.');
$lis.filter(selector).doWhatever();
But I don't know how to integrate these two scripts together?