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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:18:24+00:00 2026-06-03T01:18:24+00:00

UPDATE 2: Thanks so much for all your help. While all three solutions worked,

  • 0

UPDATE 2:

Thanks so much for all your help. While all three solutions worked, I like Bill’s in terms of readability and performance. As always, I’m amazed by the level of expertise and help here. REALLY appreciate the help.

UPDATE:

Put demo up on jsfiddle: http://jsfiddle.net/FC4QE/17/

I need to create a filter. Users click on a brand name link and if there is a match then I need to filter out the other products. The brand is contained in a product name, so I’m searching for a match and if there is one or many, I need to hide the other products.

I have the following javascipt/jquery code:

$(function(){   
    $('#filter-by-brand li a').click(function(){
        // get html string of clicked item
        var brandNameSelected = $(this).html();
        var productContainer = $('#product-collection div.productBoxWrapper');

        // reset products in the view
        if (brandNameSelected == 'All Brands'){
            productContainer.fadeIn("slow");
        }
        // for each product title (a tag)
        $("#product-collection h4 a").each(function(){
            var productTitle = jQuery(this).html();

            // if item clicked is contained inside product title, hide all 
            // products and only show the ones where the title matched
            if(productTitle.indexOf(brandNameSelected) != -1){
                // hide container of all products, this hides all products
                productContainer.fadeOut("slow");
                // then show only ones that match. the problem is that only the one product is 
                // displayed since we're inside the .each. How can I show all  products where product title contains the item clicked? 
                $(this).parent().parent().parent().parent().fadeIn("slow");
            }
        });
    });
});

I explained everything in the comments inside the code, but basically, while the code works, because I’m showing the products where item clicked is contained inside the .each method, it only shows the last item matched. How can I show all the matched ones inside the .each or is this impossible and is there another way?

Hope this makes sense and that someone might have some advice!
Thanks.

  • 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-03T01:18:25+00:00Added an answer on June 3, 2026 at 1:18 am

    I got the nicest looking results from this:

    $('#filter-by-brand li a').click(function() 
    {
        var brandNameSelected = $(this).html();
        var productContainer = $('#product-collection .product-container');
    
        if (brandNameSelected == 'All Brands')
        {
            productContainer.fadeIn("slow");
        }
        else {
            $(".product-container")
                .fadeOut(100)
                .delay(100)
                .filter(function() {
                  return $(this).html().indexOf(brandNameSelected) > -1;  
                })
                .each(function(index, item) {
                    $(item).fadeIn("slow");
                });
    
    
        }
    });
    

    You can play with it at http://jsfiddle.net/tu8tc/1/;

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

Sidebar

Related Questions

UPDATE: Thank you all so much for your help on this. I've taken a
UPDATE : Thank you all who tried to help. I appreciate your time. As
Update Thanks to Marc's help the AlphaPagedList class is now available on CodePlex if
Update: Thanks guys, I didn't realize it was very close to zero but not
UPDATE: Solved. Thanks BusyMark! EDIT: This is revised based on the answer below from
I've looked all over for an answer, but it seems like I'm missing something
We have a security problem here and we really need your help and inputs.
Dear All, I have created an facebook application to update the user status.and it
Background First of all, much gratitude to atebits for their very informative blog post
I'm using a TIdTCPCmdServer to handle all communication with client applications. I would like

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.