Update: The code below does indeed work as expected, and accomplishes the code I wanted. My confusion was in understanding what I had in my markup when writing the code below - after giving my markup a second look, I realized my code worked perfectly.
I've provided my answer below for all who are interested in the more thorough explanation.
I'm trying to delay an action until after a $.each() cycle has completed, but cannot seem to get it working. More specifically, I'm cycling through a series of DIV's to determine the tallest, and then setting the height of all to that value, but I have to wait until I have that highest value before I can set the height of the others:
/* Fixing Module Heights */
$("div.module-box").each(function(){
maxHeight = 0;
$("div.module-body", this).each(function(){
currentHeight = $(this).height();
if (currentHeight > maxHeight) maxHeight = currentHeight;
});
$("div.module-body", this).css("height", maxHeight);
});
It should turn this:
<div class="module-box">
<div style="height:75px" class="module-body">Hello World</div>
<div style="height:10px" class="module-body">Hello World</div>
</div>
<div class="module-box">
<div style="height:50px" class="module-body">Hello World</div>
<div style="height:13px" class="module-body">Hello World</div>
</div>
Into this:
<div class="module-box">
<div style="height:75px" class="module-body">Hello World</div>
<div style="height:75px" class="module-body">Hello World</div>
</div>
<div class="module-box">
<div style="height:50px" class="module-body">Hello World</div>
<div style="height:50px" class="module-body">Hello World</div>
</div>