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

  • Home
  • SEARCH
  • 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 8133547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:38:39+00:00 2026-06-06T09:38:39+00:00

I would like the top_content function to cross fade with #test and #test1. Right

  • 0

I would like the top_content function to cross fade with #test and #test1. Right now the divs #test, and #test1 are using a simple toggle but I would like them both fade out and in at same time.

$(document).ready(function () {
    $('#test, #test1').hide();
    $('.home').click(function () {
        var id = $(this).html().toLowerCase();
        var $top_content = $('#' + id + ':not(:visible)');
        if ($('.current').length === 0) {
            toggleContent($top_content);
        } else {
            $('.current').toggle(400, function () {
                toggleContent($top_content);
            });
        }
    });

    function toggleContent(top_content) {
        top_content.toggle(400);
        $('.current').removeClass('current');
        top_content.addClass('current');
    }
    $("a.home").click(function () {
        $('.active').not(this).removeClass('active');
        $(this).toggleClass('active');
    });
});

http://jsfiddle.net/FJ8DV/

  • 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-06T09:38:43+00:00Added an answer on June 6, 2026 at 9:38 am

    The reason you’re not getting a “cross fade” effect is this code:

            $('.current').toggle(400, function () {
                toggleContent($top_content);
            });
    

    You’ve placed the call to your toggleContent() function in the callback that is called on completion of the .toggle() – so the fade in doesn’t happen until the previous fade out is finished. Move that out of the callback and it won’t wait for completion thus allowing the animations to happen simultaneously:

            $('.current').toggle(400);
            toggleContent($top_content);
    

    Also, I assume “cross fade” means the elements should appear in the same place at the same time, so you’ll need to give them position:absolute styling:

    #top_content div { position : absolute; }
    

    Given that you’re talking about a cross fade, you might like to replace .toggle() with fadeToggle() as shown in this update to your demo (I’ve also used a longer delay so the fade is more obvious): http://jsfiddle.net/FJ8DV/1/

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

Sidebar

Related Questions

I would like to have a header on top of a ListView , but
I would like to get rid of the close/X button on the top right
I would like to have a function called in an onclick handler, within an
Yes, this sounds like a simple question, and it probably is. But when i
I would like to create a simple mootools popup as follows. <?php for($i=1;$i<10;$i++) :
I would like to use the top 5 to capture the top 5 for
I would like to show different tabs in the top navigation of a SharePoint
I would like to put a button on top of a Google Map next
I would like to add a uitoolbar able to slide -in from the top
I would like to make a button with large hover picture on top of

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.