Ok, so I have this jquery function to that grabs the checkbox's value and uses as identifier to show or hide an ul
The problem is that I couldn't manage to add an if only 1 choice in checkbox add X.
Here is the code and what I have tried
$('#filter li input:checkbox').change(
function(){
var show = $('input:checkbox:checked').map(function(){
return $(this).val();
});
if (show.length > 0)
{
$('#list li').each(
function(){
/*if ($.inArray($(this).attr('class'),show) <= 1)
{
console.log($(this));
}
else */if ($.inArray($(this).attr('class'),show) > -1)
{
$(this).show();
}
else
{
$(this).hide();
}
});
}
else {
$('#list li').show();
}
});
I don't really understand how this works: if ($.inArray($(this).attr('class'),show) > -1) because I have tried if ($.inArray($(this).attr('class'),show) = 1) and nothing