I am a total jquery newb and I have a deadline for this project so please don’t laugh.
I am trying to make this jquery code work:
function resize_images(){
var def = $(".defx img").height(); // get the desired height
$(".model").each(function() { // loop through all images inside model divs
var images = $(this).find("img"); // find the image
var height = images.height(); // find the image height
if (height > def){ images.css("height: "+def+"px !important"); } // if the image height is larger than the default add a css rule
});
}
Any ideas why it is not working?
You’re only checking the height of the first
img. Loop over the images themselves: