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 3311222
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:51:06+00:00 2026-05-17T21:51:06+00:00

I have some filters on the left. Each filter has an id. The id

  • 0

I have some filters on the left. Each filter has an id. The id of that filter is used to filter some results that have the id of the filter in their classes.

Filters refer to characteristics of products.. example

<a id="filter_colorRED">RED</a>

...

<li id="item4" class="filter_colorBLUE">Blah Blah</li>
<li id="item5" class="filter_colorRED ">Blah Blah</li>
<li id="item6" class="filter_colorRED filter_colorBLACK">Blah Blah</li>

I am looking for the best method to find which filters should be disabled. Disabled filters should be these that dont exist in visible items’ classes.

For example if colorBlue is applied RED and BLACK should be disabled because the only <li> that has the BLUE class doesn’t contain RED or BLACK.

My only thought is for each filter to check against results .hasclass(filter's id) but I think that this is poor. Any other idea?

  • 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-05-17T21:51:07+00:00Added an answer on May 17, 2026 at 9:51 pm

    Simple approach:

    $("a").click(function () {
      $("li").hide().hasClass(this.id).show();
    });
    

    Optionally you can choose a variant:

    $("a").click(function () {
      var a = this;
      $("li").toggle(function() { return $(this).hasClass(a.id); });
    });
    

    toggle() accepts a function that returns true or false in order to show or hide an element. You could do some more complex calculations in the toggle() function. If you just check for hasClass(), the first approach is the better one.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a listing in an UpdatePanel I have some filters for that list
I have some drop-down boxes that act as filters on a page. When either
I have some items that I'd like the user to be able to filter
I have some filters expressed as a list of function List(MyClass => Boolean) .
I have a search page and want to add some filters to it, my
I have some filter and one grid.And grid have some buttons like modify/edit.I am
I'm trying to filter some XML in JavaScript using E4X and have some specific
I have some text i need to filter out a list of bad words
I have some codes like this: cats = Category.objects.filter(is_featured=True) for cat in cats: entries
I have got some lists, and I want to filter elements from them. Here's

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.