The title of this question may be misleading, but I could not think of a better way to word it.
Let me get to the point. I am using buttons to filter a table of statuses. If I have button A and button B active, I only want to display A and B, the rest are hidden. Currently I can only have it display either A or B, not both.
var aSelected = [];
$(".admin_view #filterTable tr td button").on("click", function() {
$(this).toggleClass("selected"); //class to show user button is active
//Add to array if not in already
if ($.inArray(this.id,aSelected) == -1) {
aSelected.push(this.id);
//Remove from array if button is not active
} else if ($.inArray(this.id,aSelected) >= 0) {
aSelected.splice(aSelected.indexOf(this.id), 1);
}
//Show all if array is empty
if (!aSelected.length) {
$(".admin_view #applicantTable tbody tr").each(function() {
$(".admin_view #applicantTable tbody tr").removeClass("hidden");
});
}
//This is the section I need help with
$.map(aSelected, function(a) {
$(".admin_view #applicantTable tbody tr").not("."+a).addClass("hidden");
$(".admin_view #applicantTable tbody tr."+a).removeClass("hidden");
});
});
I need to find a way to compare against the entire array, not against one piece.