Question:
I want to filter my divs by type of it (hotel/hostel), and the city where it is located. I have added filtering by type of property, but don’t know how to add one more filter, and how to make it work good simultaneously. First filter looks like checkboxes, second is radiobuttons. Divs:Answer:
You need to keep track of both the selections separately and finally decide what to show.type
is a kind of OR
operation as it is allowed to be one of many options. city
is must have a property in your div classes.The following code will work as you expect with both checkboxes and radio buttons. It can be extended as you want.
Note that I have added a common CSS class (“item”) to all the items you gonna either show or hide, to make it easier to select them easily.
If you have better answer, please add a comment about this, thank you!