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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:30:34+00:00 2026-06-11T10:30:34+00:00

For a page I’m creating which dynamically displays product, I’m needing to create a

  • 0

For a page I’m creating which dynamically displays product, I’m needing to create a product filter of sort. Clicking on a li element in the ul#product-filter will show/hide the appropriate div (product category).

See my HTML code:

<ul id="product-filter">
    <li class="cat_1">category 1</li>
    <li class="cat_2">category 2</li>
</ul>

<div id="product-display">
    <div class="cat_1">
        <img src="image1.gif">
    </div>

    <div class="cat_2">
        <img src="image2.gif">
    </div>
</div>

Currently my jQuery solution is:

$('#products-filter li[class^=cat_]').click(function() {
    $('#products-display div[class=' + $(this).attr('class') + ']').fadeToggle();
});

However, this only fadeToggles the selected category (product category div). The client has requested that clicking an initial category (‘li’) would hide all other ‘product category’ divs and display only the selected. Clicking another (‘li’) category would also show this second product div, still showing the previous selected.. etc. Re-clicking this same ‘li’ item would hide the category again.. etc.

A ‘reset’ button would also be ideal.

Any suggestions would be greatly appreciated.

  • 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-11T10:30:36+00:00Added an answer on June 11, 2026 at 10:30 am

    I think this implements the “client requested behavior” of the first click shows only the items clicked on and subsequent clicks just toggle the clicked on items (leaving the others as they were):

    var clickOnce = false;
    $('#product-filter li').click(function() {
        if (!clickOnce) {
            $('#product-display > div').hide();
            $('#product-display .' + this.className).show();
            clickOnce = true;
        } else {
            $('#product-display .' + this.className).toggle();
        }
    });​
    

    Working demo: http://jsfiddle.net/jfriend00/KHeVp/

    To just show the clicked on ones and hide all others (a more traditional behavior), you could use this:

    $('#product-filter li').click(function() {
        $('#product-display > div').hide();
        $('#product-display .' + this.className).show();
    });​
    

    Working Demo: http://jsfiddle.net/jfriend00/Tcjam/

    Or with an animation:

    $('#product-filter li').click(function() {
        $('#product-display > div:visible').slideUp();
        $('#product-display .' + this.className).stop(true).slideDown();
    });​
    

    Working Demo: http://jsfiddle.net/jfriend00/ZThzA/

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

Sidebar

Related Questions

page.xml.php will not show any output, in firebug I can see the get response
My page loads a TextView which is scrollable. Unfortunately the position appears to stick
Basically, what I'm trying to create is a page of div tags, each has
Page - http://blu-eye.com/index.html - contains suckerfish menu which is displaying correctly on the rest
page--node--edit.tpl.php works just fine when you want to create a specific template for editing
Page has rows which is positioned relative. Each row has col1 and col2 which
Page link I am working on is http://www.whatcar.com/car-news/subaru-xv-review/260397 I am trying to automate 'clicking
page: http://jsbin.com/eniva4/edit I have one main div: #main-content which contains two div's : #announcement
My page loads jQuery. Is there any way to find out which version of
Page of the application with the TextBlock and Button, also involved .txt document with

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.