Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8449975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:50:51+00:00 2026-06-10T10:50:51+00:00

I am trying to build an extremely simple filter system that is based on

  • 0

I am trying to build an extremely simple filter system that is based on multiple attributes.

In the case of my example, I used:

  • Gender
  • Height

I would like to be able to choose between ‘Male/Female’ and ‘Short/Tall’. So, there are four possible combinations:

  • Male/Short
  • Male/Tall
  • Female/Short
  • Female/Tall

In the case of having only two choices in each filter group, only one can be checked at a time.

The problem I am running into is the simple logic. Right now, clicking ‘Men’ will hide the women. But clicking ‘Tall’ will show only the ‘Tall’ people.

I’m just wondering if there is an elegant solution to building this basic system?

Thank you!

http://jsbin.com/ixokek/1

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T10:50:52+00:00Added an answer on June 10, 2026 at 10:50 am

    You only care for the current filter setting; you do not take the other into account. It would be arguably more elegant if there is a common filter function that reads all filter settings, and a click handler that merely swaps the active state: http://jsbin.com/ixokek/7/.

    $('#filter li').click(function(){
        $(this).siblings().removeClass("active");  // remove active from other
        $(this).toggleClass("active");  // toggle active on current
        filter();  // filter elements
    });
    
    var filter = function() {
      // array of classes that items need to have
      var classes = $("#filter li.active")
          .map(function() {
            return $(this).data("filter");
          })
          .toArray();
    
      $(".item").each(function() {
        var $this = $(this);
    
        // it should show if it has all classes as the settings say
        var show = classes.every(function(aClass) {
          return $this.hasClass(aClass);  // class is a reserved word
        });
    
        // toggle appropriately
        if(show) {
          $this.fadeIn(200);
        } else {
          $this.fadeOut(200);
        }
      });
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to build a extremely basic content management system. I want to do
I'm trying to build an extremely simple RESTful test rig for an app I'm
I'm trying to separate a Java Library, that is used by multiple Android services,
Trying to build sslsniff on a RHEL 5.2 system here. When compiling sslsniff on
I'm trying build a regex that will replace any characters not of the format:
Trying to build a plugin effect that will some what look better than this
trying to build an ad hoc distribution with Xcode 4. Consider that my project.xcodeproj
Trying to build a linq query based on parameters a user selects (reporting) but
Trying to build a function that can insert into a SQL database regardless of
I'm brand new to this and I'm trying build a simple layout of divs.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.