I have a set of div
that I can show or hide by using checkboxes
. I am using jQuery to find the div
with a certain CSS class, and just display them.
The html is the following:
<div class="inputs">
<input class="filterbox" type="checkbox" value="azul" />Azul
<input class="filterbox" type="checkbox" value="verde" />Verde
<input class="filterbox" type="checkbox" value="rojo" />Rojo
</div>
<br>
<div class="tags azul">Azul</div>
<div class="tags verde azul">Verde y Azul</div>
<div class="tags verde rojo">Verde y Rojo</div>
Javascript / jQuery
$('input').click(function() {
$('.tags').hide();
$('input:checked').each(function(i) {
$('div.' + $(this).val()).show();
});
});
The problem I have is that if I select both blue and green, instead of just a div
, it shows all three, since all div
have the blue or green CSS class.
What I want to do is edit the code so that when I select more than one checkbox
it only shows the div
that both CSS classes have.