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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:35:44+00:00 2026-05-13T23:35:44+00:00

I have 4 divs with content like below: <div class=prodNav-Info-Panel>content</div> <div class=prodNav-Usage-Panel>content</div> <div class=prodNav-Guarantee-Panel>content</div>

  • 0

I have 4 divs with content like below:

<div class="prodNav-Info-Panel">content</div>
<div class="prodNav-Usage-Panel">content</div>
<div class="prodNav-Guarantee-Panel">content</div>
<div class="prodNav-FAQ-Panel">content</div>

And a navigation list like this:

<div id="nav">
<ul id="navigation">
    <li><a class="prodNav-Info" ></a></li>
    <li><a class="prodNav-Usage" ></a></li>
    <li><a class="prodNav-Guarantee"></a></li>
    <li><a class="prodNav-FAQ" ></a></li>
    </ul>
</div>

When the page is first displayed I show all the content by executing this:

$('div.prodNav-Usage-Panel').fadeIn('slow');
$('div.prodNav-Guarantee-Panel').fadeIn('slow');
$('div.prodNav-FAQ-Panel').fadeIn('slow');
$('div.prodNav-Info-Panel').fadeIn('slow');

Now, when you click the navigation list item it reveals the clicked content and hides the others, like this:

    $('.prodNav-Info').click( function() {
        $('div.prodNav-Info-Panel').fadeIn('slow');
        $('div.prodNav-Usage-Panel').fadeOut('slow');
        $('div.prodNav-Guarantee-Panel').fadeOut('slow');
        $('div.prodNav-FAQ-Panel').fadeOut('slow');
    });

So what I have is 4 separate functions because I do not know which content is currently displayed. I know this is inefficient and can be done with a couple of lines of code. It seems like there is a way of saying: when this is clicked, hide the rest.

Can I do this with something like $(this) and $(not this)?

Thanks,
Erik

  • 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-13T23:35:45+00:00Added an answer on May 13, 2026 at 11:35 pm

    In your particular case you maybe able to use the .sibilings() method something like this:

    $(this).fadeIn().sibilings().fadeOut()
    

    Otherwise, lets say that you have a set of elements stored somewhere that points to all of your elements:

    // contains 5 elements:
    var $hiders = $(".prodNavPanel");
    
    // somewhere later:
    $hiders.not("#someElement").fadeOut();
    $("#someElement").fadeIn();
    

    Also, I would suggest changing the classes for your <div> and <a> to something more like:

    <div class="prodNavPanel" id="panel-Info">content</div>
    ....
    <a class="prodNavLink" href="#panel-Info">info</a>
    

    This gives you a few advantages over your HTML. First: the links will have useful hrefs. Second: You can easily select all your <div>/<a> tags. Then you can do this with jQuery:

    $(function() {
      var $panels = $(".prodNavPanel");
      $(".prodNavLink").click(function() {
         var m = this.href.match(/(#panel.*)$/);
         if (m) {
           var panelId = m[1];
           $panels.not(panelId).fadeOut();
           $(panelId).fadeIn();
           return false; // prevents browser from "moving" the page
         }
      });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several divs like this <div rel=5> Divs content goes here </div> <div
I have three DIVs, something like this: <div id=header> ... </div> <div id=content> <div
I have three divs, within a content div. Container width 70%. Within that I
I have two divs inline-table(content and sidebar) and I would like to have the
I have a div with a table inside and several content divs in cells.
The Idea I have a main PHP page that loads content in DIV's from
I have a list which have divs inside it.. Now when i use nested
I have two divs floated next to one another: <div id=parent> <div id=child_1 style=float:left>
On my page I have one navigation menu and two content containers. The content
I have a header. Below that header I have a wrapper containing 2 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.