Strange Behaviour with .next() and a Simple Slideshow with jQuery
<p>I've been banging my head against a wall with this one for a couple of hours now - no luck. In short, I can't seem to get the desired functionality from the next() jQuery method. I'm trying to make the next img tag in the DOM appear when clicking the image.</p>

<pre><code>$(images).each(function(i){

    $('#images').append($(this).css({

        'display':(i) ? 'none' : 'in-line'

    }).click(function(){

        $(this).next().css({'display':'in-line'});

        $(this).css({'display':'none'});

    }));
});
</code></pre>

<p>The required image dissappears, but the 'next()' one doesn't show. What's the big idea? Here's the environment:</p>

<pre><code>&lt;div id="images"&gt;
    &lt;img src="imgs/1.jpg" style="width: 333.33333333333337px; height: 500px; position: absolute; top: 50%; left: 50%; margin-top: -250px; margin-left: -166.66666666666669px; display: none; "&gt;
    &lt;img src="imgs/2.jpg" style="width: 333.3333333333333px; height: 500px; position: absolute; top: 50%; left: 50%; margin-top: -250px; margin-left: -166.66666666666666px; display: none; "&gt;
    &lt;img src="imgs/3.jpg" style="width: 333.3333333333333px; height: 500px; position: absolute; top: 50%; left: 50%; margin-top: -250px; margin-left: -166.66666666666666px; display: none; "&gt;
    &lt;img src="imgs/4.jpg" style="width: 333.3333333333333px; height: 500px; position: absolute; top: 50%; left: 50%; margin-top: -250px; margin-left: -166.66666666666666px; display: none; "&gt;
    &lt;img src="imgs/7.jpg" style="width: 500px; height: 333.3333333333333px; position: absolute; top: 50%; left: 50%; margin-top: -166.66666666666666px; margin-left: -250px; display: none; "&gt;
&lt;/div&gt;
</code></pre>

<p>Is this something to do with the fact that these elements are dynamically created via jQuery? It's worth noting that the iteration over the dynamically created elements only get kicked off after the images have loaded.</p>

<p>Thanks.</p>
