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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:45:31+00:00 2026-06-15T14:45:31+00:00

I am building a dynamic filtering navigation bar for use with the isotope items

  • 0

I am building a dynamic filtering navigation bar for use with the isotope items in my document. I have a few different categories in my nav, each with relative subcategories. I am trying to build a nav where the Main categories show on load.

On load I also populate the DOM with all of the elements in random order. When you click a category link it filters out the results, and organizes the relative elements. I also want to show the relative subcategories to the filtered section. Then if you select a different category, the existing subnav fades out, and the relative sub nav fades in.

All of my sorting and everything relative to isotope works great. Its the intelligent show/hide of the subnav I am having a hard time with.

My HTML:

<nav id="filters">
  <div id="categories">
    <h2>Select a Category:</h2>
    <br>
    <li><a href="#" data-filter="*">All Categories</a></li>
    <li><a href="#" data-filter=".autos" data-category="autos">Autos</a></li>
    <li><a href="#" data-filter=".lifestyle" data-category="lifestyle">Lifestyle</a></li>
    <li><a href="#" data-filter=".people" data-category="people">People</a></li>
    <li><a href="#" data-filter=".tech" data-category="tech">Tech</a></li>
    <li><a href="#" data-filter=".trends" data-category="trends">Trends</a></li>
    <br>
  </div>
  <div id="autos">
    <h2>Autos:</h2>
    <li><a href="#" data-filter=".autos" data-category="autos">Show All</a></li>
    <li><a href="#" data-filter=".news" data-category="autos">News</a></li>
    <li><a href="#" data-filter=".car-tech" data-category="autos">Car Tech</a></li>
    <li><a href="#" data-filter=".fuel-economy-and-safety" data-category="autos">Fuel Economy &amp; Safety</a></li>
    <li><a href="#" data-filter=".buying-and-selling" data-category="autos">Buying &amp; Selling</a></li>
    <li><a href="#" data-filter=".autos, .everything-else" data-category="autos">Everything Else</a></li>
    <br>
  </div>
  <div id="lifestyle">
    <h2>Lifestyle:</h2>
    <li><a href="#" data-filter=".lifestyle" data-category="lifestyle">Show All</a></li>
    <li><a href="#" data-filter=".travel" data-category="lifestyle">Travel</a></li>
    <li><a href="#" data-filter=".music" data-category="lifestyle">Music</a></li>
    <li><a href="#" data-filter=".food" data-category="lifestyle">Food</a></li>
    <li><a href="#" data-filter=".shopping" data-category="lifestyle">Shopping</a></li>
    <li><a href="#" data-filter=".lifestyle, .everything-else" data-category="lifestyle">Everything Else</a></li>
    <br>
  </div>
  <div id="people">
    <h2>People:</h2>
    <li><a href="#" data-filter=".people" data-category="people">Show All</a></li>
    <li><a href="#" data-filter=".who-you-know" data-category="people">Who You Know</a></li>
    <li><a href="#" data-filter=".who-you-should-know" data-category="people">Who You Should Know</a></li>
    <li><a href="#" data-filter=".people, .everyone-else" data-category="people">Everyone Else</a></li>
    <br>
  </div>
  <div id="tech">
    <h2>Tech:</h2>
    <li><a href="#" data-filter=".tech" data-category="tech">Show All</a></li>
    <li><a href="#" data-filter=".business" data-category="tech">Business</a></li>
    <li><a href="#" data-filter=".pleasure" data-category="tech">Pleasure</a></li>
    <li><a href="#" data-filter=".tech, .everything-else" data-category="tech">Everything Else</a></li>
    <br>
  </div>
  <div id="trends">
    <h2>Trends:</h2>
    <li><a href="#" data-filter=".trends" data-category="trends">Show All</a></li>
    <li><a href="#" data-filter=".online" data-category="trends">Online</a></li>
    <li><a href="#" data-filter=".offline" data-category="trends">Offline</a></li>
    <li><a href="#" data-filter=".trends, .everything-else" data-category="trends">Everything Else</a></li>
  </div>
</nav>

My jQuery:

$(document).ready(function() {

  $('#filters > div:gt(0)').hide();

  $('#filters a').click(function(){
    var selector = $(this).attr('data-filter');
    var category = $(this).attr('data-category');
    var $subnav = $('#filters').find('#'+category);

    if($subnav.is(":hidden")) {
      $subnav.fadeIn();
    } 

    if($subnav.is(":visible") && $subnav.attr("id") != category) {

    }

    $container.isotope({ filter: selector });
    return false;
  });
});

I am open to any suggestions. Whether it is restructuring my nav, or redaclaring my variables in a new fashion. I have been staring at this block of code for a while, and brain is turning to mush. I was trying to use the second if statement to handle the hiding of the non-relative subnav.

If you like you can hop over to my site with the example on display:

EXAMPLE

  • 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-15T14:45:33+00:00Added an answer on June 15, 2026 at 2:45 pm

    Well, I figured it out. No changes to the HTML. Heres my updated JavaScript/jQuery

    $(document).ready(function() {
    
      $('#filters > div:gt(0)').hide();
    
      $('#filters a').click(function(){
        var selector = $(this).attr('data-filter');
        var category = $(this).attr('data-category');
        var $subnav = $('#filters #'+category);
    
        $('#filters > div').each(function() {
          if($(this).attr('id') != category) {
            $(this).not('#categories').fadeOut();
          }
        })
    
        if($subnav.attr("id") === category) {
          $subnav.delay(1000).fadeIn();
        } 
    
        $container.isotope({ filter: selector });
        return false;
      });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building an application which will have dynamic allocated objects of type A each
I'm building a WinForm with quite a few dynamic elements, and I think I'm
Building an inventory system. I have lots of products and each product has three
I'm currently building a dynamic website based on jQuery en hashChanged. Currently I use
I am building a dynamic partial load asp.net page, I would like to use
I am building a dynamic dropdown navigation. In the dropdown there are multiple floating
Is it a good programming way to use xml config file for building dynamic
When building dynamic websites I use a php include to make my connections to
I have been building a dynamic form in my Zend Framework application using Jquery
hi i am building a dynamic web project in which the welcome page have

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.