Last active
December 21, 2015 12:29
-
-
Save benbabics/6306371 to your computer and use it in GitHub Desktop.
function to equalize the heights of elements of a module between modules.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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