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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:13:17+00:00 2026-05-27T19:13:17+00:00

I’m trying to structure a group of links that will .fadeIn() <div> s based

  • 0

I’m trying to structure a group of links that will .fadeIn() <div>s based on which ones are clicked. I would like to .fadeOut() any <div>s that don’t coincide with the current link that is clicked. I’m hoping it would also be possible to show all/hide all with a link as well.

For example :

<a href="#" id="showall">Show All</a>
<a href="#" id="link1">Link 1</a>
<a href="#" id="link2">Link 2</a>
<a href="#" id="link3">Link 3</a>
<a href="#" id="link4">Link 4</a>


<div class="all">
   <div class="part1">SOME TEXT</div>
   <div class="part2">SOME TEXT</div>
   <div class="part3">SOME TEXT</div>
   <div class="part4">SOME TEXT</div>
</div>

So clicking link 1 would show part 1, and so on and so on. Now I can’t seem to wrap my head around this, because originally my thought was to have a function for each link clicked that read something like :

 $("#link1").click(function() {
   $(".all").fadeOut();  //clear any divs that may be visible now
   $(".part1").fadeIn();  // display div coinciding with link   
 });

And then for show all simply have :

 $("#showall").click(function() {
   $(this).toggle("slow");
 });

But, of course I learned that by changing the visibility of a container, all elements within that container will be rendered invisible as well, regardless of if there are two commands in the function (I think.)

So instead, my thought was to write a function for each link that read

 $("#link1").click(function() {
   $(".part2, .part3, .part4").fadeOut();  //clear other divs
   $(".part1").fadeIn();  // display div coinciding with link   
 });

But I could have upwards of 25 links, and I already know there must be a more efficient way of doing this. Is it possible to have a filter, perhaps .all:visible to tell which are visible and which are not, and then have those fade out?

  • 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-27T19:13:17+00:00Added an answer on May 27, 2026 at 7:13 pm

    For the first part, clicking link1 should hide all divs but the one with class=part1

    $("#link1").click(function() {
        $("div[class^=part]").fadeOut();
        $("div.part1").fadeIn();
    });
    

    And then for show all

    $("#showall").click(function() {
        $("div[class^=part]").fadeIn();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to run a str_replace or preg_replace which looks for certain words
I'm trying to select an H1 element which is the second-child in its group
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I need a function that will clean a strings' special characters. I do NOT

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.