spsaucier
11/26/2013 - 12:52 AM

jQuery function to equalize heights of a set of elements. HTML structure for example call: div.equalize>div*4

jQuery function to equalize heights of a set of elements. HTML structure for example call: div.equalize>div*4

$(window).on('load resize', function(){
    $('.equalize > *').equalHeights();
});

$.fn.equalHeights = function() {
    var maxHeight = 0,
        $this = $(this);
    $this.each( function() {
        $(this).css('min-height', 'none');
        var height = $(this).outerHeight();
        if ( height > maxHeight ) { maxHeight = height; }
    });
    return $this.css('min-height', maxHeight);
};