jeudi 1 juin 2017

jquery show and hide dives, with multi classes

i got 3 types of classes on my page, one is class="category_one", class="category_one category_two", class="category_two".

I also have checkboxes, one to hide category_one , and one to hide category_two.

$(".category_one").show();              // to be shown by default
$(".show_one").click(function() {
    if($(this).is(":checked")) {
        $(".category_one").show();
    } else {
        $(".category_one").hide();
    }
});

I have other code to hide and show category_two. It work for category_one and for category_two, but i have problem with div class="category_one category_two".

There must be some way but haven't figure it out, to hide category_one when first checkbox is unchecked, hide category_two when second checkbox is unchecked, and hide category_one category_two only when both are unchecked.

div class="category_one category_two" should be shown when only one checkbox is unchecked

I want also make it work when i add category_tree and there will be dives class="category_one category_two category_three".

I saw some silimar topics but didnt found the answer for me. sorry if there is answer but i didnt check properly Thanks you for any IDEAS couse i dont know how to do it even teoreticly




Aucun commentaire:

Enregistrer un commentaire