• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: Add 1 more filter for divs in a JavaScript

Resolved: Add 1 more filter for divs in a JavaScript

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

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!

javascript
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: Use Svelte Component as Slot

26/03/2023

Resolved: Vaadin 14.9 – Redirect on Session Destroy Event

26/03/2023

Resolved: How to separate multiple answers in one column, for multiple columns, by creating extra columns

26/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.