I\'m pretty sure this will be a really easy answer for you jQuery whizzes, and I\'m also pretty such it involves a loop of some kind.
I\'m trying to perform essentially
You're right that it involves a loop, but this is, at least, made simple by use of the each()
method:
$('.target').each(
function(){
// iterate through each of the `.target` elements, and do stuff in here
// `this` and `$(this)` refer to the current `.target` element
var images = $(this).find('img'),
imageWidth = images.width(); // returns the width of the _first_ image
numImages = images.length;
$(this).css('width', (imageWidth*numImages));
});
References: