Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery gallery fade in/out
    text
    copied!<p>I am building a simple image gallery based on the following markup:</p> <pre><code>&lt;div id="image-list"&gt; &lt;ul&gt; &lt;li id="image-1"&gt; &lt;img src="myimage1.jpg" width="500" height="500" alt="My Image" /&gt; &lt;/li&gt; &lt;li id="image-2"&gt; &lt;img src="myimage2.jpg" width="500" height="500" alt="My Image" /&gt; &lt;/li&gt; &lt;li id="image-3"&gt; &lt;img src="myimage3.jpg" width="500" height="500" alt="My Image" /&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;ul id="thumb-list"&gt; &lt;li id="thumb-1"&gt;&lt;img src="myimage1-thumb.jpg" width="50" height="50" alt="My Image" /&gt;&lt;/li&gt; &lt;li id="thumb-2"&gt;&lt;img src="myimage2-thumb.jpg" width="50" height="50" alt="My Image" /&gt;&lt;/li&gt; &lt;li id="thumb-3"&gt;&lt;img src="myimage3-thumb.jpg" width="50" height="50" alt="My Image" /&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>I have styled this using CSS so that only one of the larger images is visible at one time (using overflow: hidden with a fixed container height).</p> <p>I am then using jquery to absolutely position the UL within the container to show each image, using the following markup:</p> <pre><code>$('#thumb-list li img').click(function() { var image = $(this).parent().attr('id').substring(6); var position = $('#image-' + image).position(); $("#image-list ul").css({'top' : '-' + position.top +'px'}); }); </code></pre> <p>Basically I want to fade out the entire "#image-list ul" while it's position is changed and then fade it back in to show the new image.</p> <p>Could someone suggest the most efficient way to do this? - any help is much appreciated!</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