calculating the width of a list of loaded images using jquery
<p>I'm creating a slide show using <strong>jQuery</strong>, the images are loaded using <strong>AJAX</strong> and are put into the list using append. After all images are loaded I want to get the list width.</p>

<p>I'm using this code below, but the problem is that <code>logos_counter</code> which is supposed to contain all images width is always equal to 0. </p>

<pre><code>var logos_counter = 0;
var img = new Image();
$.each(data.images, function (index, photo) {
   url = 'img/logos/' + photo;
   $('.logos ul').append($('&lt;li&gt;').append($('&lt;img/&gt;').attr('src',url).addClass('slide')));
   img.src = url;
   logos_counter = logos_counter + img.width;
});
$('.logos ul').css({width: logos_counter + 'px'}); 
</code></pre>
