Note that there are some explanatory texts on larger screens.

plurals
  1. POPre-load Next Image jQuery
    text
    copied!<p>I am creating a slideshow using nested li's:</p> <pre><code>&lt;ul id="ss_images_set"&gt; &lt;li&gt; &lt;img link="images/koala_1.jpg" /&gt; &lt;p class="img_caption"&gt;&amp;#169;Copyright&lt;/p&gt; &lt;p class="img_author"&gt;John Merriam&lt;/p&gt; &lt;p class="img_href"&gt;http://www.twitter.com&lt;/p&gt; &lt;p class="img_hashtag"&gt;JohnMerriam&lt;/p&gt; &lt;/li&gt; </code></pre> <p>I will be uploading new images daily to this slideshow, so there will be many images in the set (hundreds). There are so many pre-loaders out there that I am confused as to what to use to load only the next image. The slideshow has an image pre-loader, but I don't think it works properly because the next images are clearly not cached (content below slideshow jumps up and down when going to next image).</p> <p>Here is the pre-loader script:</p> <pre><code>function preload_images(){ var pre_image = curr_img - 1; if(pre_image &lt; 0) pre_image = (tot_elements-1); var curr_obj = 0; if(!$('#img_preloaded_'+pre_image).length &gt; 0){ curr_obj = slideshow[pre_image]; $('body').append('&lt;img src="'+curr_obj["img_url"]+'" id="img_preloaded_'+pre_image+'" class="preload_box" /&gt;'); } var pre_image = curr_img + 1; if(tot_elements==pre_image) pre_image = 0; if(!$('#img_preloaded_'+pre_image).length &gt; 0){ curr_obj = slideshow[pre_image]; $('body').append('&lt;img src="'+curr_obj["img_url"]+'" id="img_preloaded_'+pre_image+'" class="preload_box" /&gt;'); } </code></pre> <p>I don't know why it's not caching. Is it written wrong? Is it in the wrong spot in the following fiddle?</p> <p>Fiddle with JS: <a href="http://jsfiddle.net/doobada/9m9eq/" rel="nofollow">http://jsfiddle.net/doobada/9m9eq/</a></p> <p>Current ex. of slideshow (content below jumps up and down): <a href="https://www.assembla.com/code/cfrepo/subversion/node/blob/trunk/index.html#image=JohnMerriam" rel="nofollow">https://www.assembla.com/code/cfrepo/subversion/node/blob/trunk/index.html#image=JohnMerriam</a></p> <p>Ok, jQuery is not my strong suite (taking the tuts+ courses now), but this shouldn't be taking me 3 weeks to figure out.</p> <p>Thanks for your help.</p>
 

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