I have a page with 3 columns in it and varying amounts of text. These 3 columns need to be the same height. I have written a function that looks at the height of each column, checks which is tallest, and then sets all of their heights to that length.
I've got an event handler on the window.onresize
event that runs this function. At the start of this function, the variable max_height
is set to 0. The problem is, it never seems to get reset to 0 after being called multiple times. The new max_height
just seems to keep being added to it, the heights of the columns grow taller on each resize. What am I missing?
function resizeHeights(){
var callouts = $('.callout');
var max_height = 0;
callouts.each(function(i){
if($(callouts[i]).height() > max_height){
max_height = $(callouts[i]).height();
console.dir(max_height);
$(callouts[i]).height(0);
}
});
callouts.each(function(i){
$(callouts[i]).height(max_height + 50);
});
}
$(window).on('resize', function(){
resizeHeights();
});