Skip to content

Instantly share code, notes, and snippets.

@benbabics
Last active December 21, 2015 12:29
Show Gist options
  • Save benbabics/6306371 to your computer and use it in GitHub Desktop.
Save benbabics/6306371 to your computer and use it in GitHub Desktop.
function to equalize the heights of elements of a module between modules.
/*
* Helper - Equalize height of elements in a module between modules
*
* @param { string } - selector ( e.g. '.header' )
* @param { element } - context ( e.g. $('#blog') )
*/
function equalHeight(selector, context) {
var maxHeight = 0
$modules = $( selector, context );
// determine the max height of modules for each row
$modules.each(function(i) {
var height = $modules.eq(i).outerHeight();
maxHeight = height > maxHeight ? height : maxHeight;
});
// set all rows to the max height
$modules.height( maxHeight );
}
// arbitrary page-level implementation
$('#companyUsers').children('.row').each(function() {
equalHeight( 'div.top', this );
equalHeight( 'div.reviews', this );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment