Javascript – How to get height of the highest children element in javascript/jQuery


I need a function to get the height of the highest element inside a div.

I have an element with many others inside (dynamically generated), and when I ask for the height of the container element using $(elem).height(), I get a smaller height than some of the contents inside it.
Some of the elements inside are images that are bigger than the size this element says to have.

I need to know the highest element so I can get it's height.

Best Solution

I found this snippet which seems more straight forward and shorter at

var maxHeight = 0;

   var thisH = $(this).height();
   if (thisH > maxHeight) { maxHeight = thisH; }