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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:35:48+00:00 2026-06-08T12:35:48+00:00

I can fade in & out different div content, but I’d like that when

  • 0

I can fade in & out different div content, but I’d like that when we open the website, the first div content is already visible.

For now, I have to click on one of the link to show the content. I want the first div visible by default, then we can fade in & out with other div contents when we click on the links. In this case, the lorem ipsum div should be visible at start when we arrive on the webpage.

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
  document.documentElement.className += " js"; // Add js class to the HTML element

  $(function(){
    var $containers = $("#animators > div").hide();

    $('a').each(function(i,el){
      var idx = i;
      $(this).click(function(e){
        var $target = $containers.filter(':eq(' + idx + ')');
        // Fade out visible div
        if($containers.filter(':visible').not($target).length){
          $containers.filter(':visible').fadeOut(700, function(){
            $target.not(':visible').fadeIn(700);
          });
        } else {
          $target.not(':visible').fadeIn(700);
        }

        e.preventDefault();
      })
    })
  });

</script>

This is my HTML part

    <div id="animators">
    <div class="container">
     <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus porttitor, est a mollis pellentesque, purus quam commodo ligula, quis laoreet ipsum enim quis nulla. Nulla leo odio, sollicitudin ut cursus lacinia, placerat in erat. Donec tempor justo vitae enim varius eu placerat arcu pulvinar. Integer fermentum placerat diam, eget bibendum lacus aliquam aliquet. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. In tellus tortor, fringilla in pulvinar a, ultrices eget magna. Nam in cursus tellus. Donec gravida semper massa in pulvinar. Proin ac dolor nulla, eget vestibulum dui. Vivamus pulvinar ullamcorper ligula nec sollicitudin. Nunc pulvinar cursus tempus.</p>
    </div>
    <div class="container">
     <ul>
      <li>stuff2</li>
      <li>stuff2</li>
      <li>stuff2</li>
     </ul>
    </div>
    <div class="container">
     <ul>
      <li>stuff3</li>
      <li>stuff3</li>
      <li>stuff3</li>
     </ul>
    </div>
    <div class="container">
      <li>stuff4</li>
      <li>stuff4</li>
      <li>stuff4</li>
    </div>
</div>

And my CSS part even though it’s not important in this case

.js #animators { position: absolute; height: 300px}
.js #animators div.container { position: absolute; left: 0; top: 0 }
  • 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-08T12:35:51+00:00Added an answer on June 8, 2026 at 12:35 pm

    You’ve already retrieved the container div elements in your $containers variable. You can use this to show the first div and avoid having to grab it again:

    var $containers = $("#animators > div").hide();
    $containers.eq(0).show();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know you can fade out a <div> with jQuery, but I was wondering
How can I fade out all div's besides those with any of these three
I am wondering how I can fade out a div box before scrollable starts
I can't get the table row to fade out in IE. It works in
How can I make my jQuery multi-stage form fade out on successful submission and
I'm using Fancybox v2.0.5 and can't figure out how to fade in the overlay
It's very simple task, but somewhere is a mistake.. I can't find out it.
Note: This question was marked as solved once, but it figured out that upgrading
hello there :) Im trying to figure out how i can grab some content
I'm trying to write a simple script that effectively fades out the page content,

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.