Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I forked your fiddle and cleaned the code a little: <a href="http://jsfiddle.net/4FzqA/" rel="nofollow noreferrer">http://jsfiddle.net/4FzqA/</a>.</p> <p>After looking between my cleaned version and your original, the only difference was that the fiddle was set to "onDomReady" on mine, when yours is set to "onLoad".</p> <p>Otherwise, the code should have been functional.</p> <pre><code>window.onload = function() { var button = $("#fade_out").click(changeBackground); } function changeBackground() { $('#background').fadeOut('slow', function() { $('#background_hidden').fadeIn('slow'); }); } </code></pre> <p><strong>Edit</strong>: It looks like the window.onload was conflicting with the onLoad in the original fiddle, since the original fiddle didn't work for me. When I changed window.load to document ready, all was well, so:</p> <pre><code>$(document).ready(function() { var button = $("#fade_out").click(changeBackground); }); </code></pre> <p><strong>Another edit</strong>: If the image is large, you could try waiting for it to load, but keep in mind that the load won't trigger if pulled from cache:</p> <pre><code>$(document).ready(function(){ var img = new Image(); $(img) .hide() .load(function(){ $("body").append(this); $(this).fadeIn(3000); }) .attr("src", "files/originals/01.jpg"); }); </code></pre> <p>Taken from: <a href="https://stackoverflow.com/questions/3979552/fading-in-large-images-in-chrome">Fading in large images in Chrome</a>.</p> <p><strong>Another edit:</strong> From the sounds of it, you might be correct in guessing that it is an issue with the image size. I updated my original fiddle (<a href="http://jsfiddle.net/4FzqA/7/" rel="nofollow noreferrer">http://jsfiddle.net/4FzqA/7/</a>) with the new images and the load. Notice that the image is loaded each time which isn't very efficient. But it will give you an idea. Below is the JS:</p> <pre><code>$(document).ready(function() { var button = $("#fade_out").click(changeBackground); }); function changeBackground() { $('#background').fadeOut('slow', function () { $('#background_hidden') .attr('src', 'http://img688.imageshack.us/img688/8633/daynightm.jpg?' + (new Date()).getTime()) .load(function () { $(this).fadeIn('slow'); }); }); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload