Skip to content

Instantly share code, notes, and snippets.

@nelsnelson
Created September 25, 2015 18:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nelsnelson/f704495e29dce0c99958 to your computer and use it in GitHub Desktop.
Save nelsnelson/f704495e29dce0c99958 to your computer and use it in GitHub Desktop.
$.fn.equalHeights = function(px) {
var tallestHeight = 0;
if (!px) {
$(this).each(function() {
if ($(this).height() > tallestHeight) {
tallestHeight = $(this).height();
}
});
if (!px && Number.prototype.pxToEm) {
tallestHeight = tallestHeight.pxToEm();
}
console.log('Setting heights for elements to ' + tallestHeight);
}
$(this).each(function() {
$(this).css({'height': tallestHeight}).css({'min-height': tallestHeight});
});
return this;
};
var init_page = function() {
$('div.panel-body').equalHeights();
};
$(document).ready(init_page);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment