jeudi 24 mars 2022

jQuery filtering a close element using multiple checkboxes

I need a solution for filtering a group of items with multiple checkboxes. I found a fiddle and modified it to my needs for testing purposes:

Fiddle

Before it was based on "data-category" but I need it to be based on classes. Works just fine but there is one thing that I can't figure out myself. When filtering I don't want the actual element having the class (.red, .small, .africa) to hide or show but actually an element that it is nested in, I named it ".test" in my example and made it a div.

I think you can somehow do this using .closest('.test') but I don't know where to put it exactly.

closest()

Can you help me with this? I would really appreciate it.




Aucun commentaire:

Enregistrer un commentaire