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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:23:26+00:00 2026-05-15T04:23:26+00:00

I have a jquery bug and I’ve been looking for hours now, I can’t

  • 0

I have a jquery bug and I’ve been looking for hours now, I can’t figure out what’s wrong…
I have this code :

     $(document).ready(function(){

$('#ulPhotos a').click(function() {
    var newSrc= $(this).find('img').attr('src').split("/");
    bigPictureName = 'big'+newSrc[2];

    $('#pho').hide(); 
    $('#imageBig').attr("src", "images/photos/"+bigPictureName);
    $('#pho').fadeIn('slow');

    var alt = $(this).find('img').attr('alt'); 
    $('#legend').html(alt);
    }); 
    });

and this in html :

<ul id="ulPhotos">
    <li><a href="#centre"><img src="images/photos/09.jpg" title="La Reine de la Nuit au Comedia" alt="<em>La Reine de la Nuit</em> au Comedia"/></a>
    <a href="#centre"><img src="images/photos/03.jpg" title="Manuelita, La Périchole à l&rsquo;Opéra Comique" alt="Manuelita, <em>La Périchole</em> à l&#8217;Opéra Comique" /></a></li>
    <li><a href="#centre" ><img src="images/photos/12.png" title="" alt="Marion Baglan Carnac Ré" /></a>

and this in for bigImage :

</div>
<div id="pho"  a name="centre">
<p id="legend"> La Reine de la Nuit</p>
  <img src="images/photos/big09.jpg" alt="Marion Baglan" id="imageBig"/> 

</div>

It simply changes the source of my img in a div named pho… but sometimes when the new image is too heavy, the fadeIn executes on the previous src !! so we see the fadeIn first on the previous image, and then, the right picture appears without fadeIn….

am I missing something?

ps : the page is here http://www.marion-baglan.net/photos.htm#centre if you click fast you can see it… and when I try to put some bigger photos, it’s very obvious…

  • 1 1 Answer
  • 8 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-15T04:23:26+00:00Added an answer on May 15, 2026 at 4:23 am

    You need to use the load event like karim suggests, but in a slightly different way to work in all cases, like this:

    $('#imageBig').one('load', function() {
        $('#pho').fadeIn('slow');
    }).attr("src", "images/photos/"+bigPictureName).each(function() {
      if(this.complete) $(this).load();
    });
    

    You need to attach the load handler using .one() for 2 reasons, so we don’t add a .load() handler and every time you change the image it queues another fadeIn, and also so the next cache component doesn’t immediately trigger it twice. It’s important to set the load handler before changing the image source, as a cached image will immediately load, possibly before the handler is attached.

    The last piece, the .each() call loops through the images to see if it’s complete, if that’s the case already it was loaded from cache, and not all browsers fire the load event for this…so we’re manually firing it. The .one() call from earlier prevents this from doing anything twice.

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

Sidebar

Related Questions

Is it something wrong or jquery bug? So we have such code for example
I have jQuery code which looks something like this on Button1 Click $('table.result_grid tbody
Say I have jquery code like this: html += '<div class=index>' + item.index +
Let's assume that we have simple jQuery code like the following: var $document =
I have this basic example: <!doctype HTML> <html> <head> <script src=jquery-1.4.2.min.js type=text/javascript></script> <script> $(document).ready(function(){
I have a really weird bug and cant figure out why things are not
I have jquery validation code which is working fine in ff but the same
I keep getting this error all over the place where I only have jquery
Here is some jQuery I have coded: $(function () { $('input').click(function() { $(this).css(background, -webkit-gradient(linear,left
Edit: This is a confirmed bug in jQuery 1.3.1. It is fixed in jQuery

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.