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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:25:20+00:00 2026-05-23T21:25:20+00:00

I hope someone can help me with this. I am having some trouble figuring

  • 0

I hope someone can help me with this. I am having some trouble figuring out how to make a nice and clean fade transition between images. The code below is simplified but the jquery is more or less the same as I have in my test code. I want the fade from the current image in the “background” of the div num1 to the next image (where the next image is the thumbnail that was clicked on). The current code only seems to do this for the first one and thereafter there is no fade. How would I do this for the multiple images I have? Thanks in advance for any help.

JQuery:

jQuery(document).ready(function() {
    $(".bg_image_thumb").click(function(){
    var thumb_id = this.id;
    var main_href = $("#"+thumb_id).attr('href');
    $("#main_image").attr("src", main_href).fadeIn("slow");
    });
});

css:

#container { position: relative; }
#num1, #num2 { position: absolute;}
#num1 { z-index: 1; }
#num2 { z-index: 2; }

html:

<div id="container">
<div id="num1" style="min-height:700px;height:700px;width:700px;"><img id="main_image" src=""></div>
<div id="num2">
<a class="bg_image_thumb" id="bg_image_thumb1" onclick="return false;" href=image1.jpg"><img src="image1.jpg" /></a>
<a class="bg_image_thumb" id="bg_image_thumb2" onclick="return false;" href=image2.jpg"><img src="image2.jpg" /></a>
<a class="bg_image_thumb" id="bg_image_thumb3" onclick="return false;" href=image3.jpg"><img src="image3.jpg" /></a>
</div>
</div>

1

  • 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-23T21:25:21+00:00Added an answer on May 23, 2026 at 9:25 pm

    you need to change your fadeIn code to something like this;

    $("#main_image").fadeOut("slow", function()
    {
          $("#main_image").attr("src", main_href).fadeIn("slow");
    });
    

    this code first hides your current shown image, and after it’s finished, it will set the source and show the new image.

    [NOTES]

    1. This will give you an effect of fadeOut-then-fadeIn. If you want to have a fadeIn-fadeOut (same time) you need to use two controls for settings images.

    In this case you need to use two img controls:

    <div id='container'>
        <img id='main_image' src="http://dummyimage.com/300x200/000/fff&text=test1" />
        <img id='main_image_back' />
    </div>
    
    $("#main_image_back").attr("src", main_href).hide().fadeIn("slow", function()
    {
          $("#main_image").attr("src", $("#main_image_back").attr("src"));
          $("#main_image_back").hide();
    });
    $("#main_image").show().fadeOut("slow", function(){$(this).show();});
    

    and in your css:

    #container {position:relative;}
    #main_image_back {display:none; position:absolute; top:0; left:0;}
    

    jsFiddler link: http://jsfiddle.net/ke4kM/7/

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

Sidebar

Related Questions

I'm having some javascript conflict problem, and hope someone can help me out. I'm
Having trouble setting up a website for my wedding. Hope someone can find out
I hope that someone can help me with this problem that I've been having
I hope someone can help me with this, as I'm unable to find the
I hope someone can help here, we're having an incredibly annoying time with Visual
I'm almost losing it, i really hope someone can help me out! I'm using
I've search for some clues on this problem without much success. Hope someone can
I hope someone can help with this please. I am trying to query an
Hope someone can help with this. I've been up and down the web and
Hope someone can help me here? Having an issue getting text that's located inside

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.