I have this code for centering vertically the images in a bunch of divs.
function centerImages(parent, image) {
var parent_height = $(image).parent().height();
var image_height = $(image).height();
var top_margin = (parent_height - image_height)/2;
$(image).css( 'margin-top' , top_margin);
}
centerImages(".clients li", ".clients li img");
.. but it doesn’t seem to work.
Try this instead…
You weren’t actually passing in images, just the class selector. The above selects all relevant images and passes them in – there’s no need for the parent parameter.