Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Optimized `equalHeights()`
$.fn.equalHeights = function( px ) {
$( this ).each( function() {
var currentElement,
currentHeight,
currentTallest = 0,
children = $( this ).children();
children.each( function() {
currentElement = $( this );
currentHeight = currentElement.height();
if ( currentHeight > currentTallest ) currentTallest = currentHeight;
});
if ( !px || !Number.prototype.pxToEm ) currentTallest = currentTallest.pxToEm(); //use ems unless px is specified
// for ie6, set height since min-height isn't supported
if ( $.browser.msie && $.browser.version == 6.0 ) {
children.css({
'height': currentTallest
});
} else {
children.css({
'min-height': currentTallest
});
}
});
return this;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment