Skip to content

Instantly share code, notes, and snippets.

@ashhitch
Created February 20, 2014 16:00
Show Gist options
  • Select an option

  • Save ashhitch/9116998 to your computer and use it in GitHub Desktop.

Select an option

Save ashhitch/9116998 to your computer and use it in GitHub Desktop.
jQuery functions to make all columns/objects the the same height. Runs through each element and then sets each the the highest one.
function checkAllHeights(row, item) {
if ($(row).length !== 0) {
var itemHeight = 0;
//reset size
$(row + ' ' + item).removeAttr('style');
//Check heights
$(row + ' ' + item).each(function (index) {
if (($(this).height() > itemHeight)) {
itemHeight = $(this).height();
}
}).promise().done(function () {
//Once done set all to the highest
$(row + ' ' + item).height(itemHeight);
});
}
}
$(window).load(function () {
//Pass containing row and item classes
checkAllHeights('.check-height', '.check-height-item');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment