Skip to content

Instantly share code, notes, and snippets.

@jjeaton
Created October 7, 2014 14:22
Show Gist options
  • Save jjeaton/32d36fdd94206b374d33 to your computer and use it in GitHub Desktop.
Save jjeaton/32d36fdd94206b374d33 to your computer and use it in GitHub Desktop.
//********************************************************
// plugin for equalizing heights, responsively
//********************************************************
(function ($) {
$.fn.eqHeights = function() {
var el = $(this);
if (el.length > 0 && !el.data('eqHeights')) {
$(window).on('resize.eqHeights', function() {
el.eqHeights();
});
el.data('eqHeights', true);
}
return el.each(function() {
var curHighest = 0;
$(this).children().each(function() {
var el = $(this),
elHeight = el.height('auto').height();
if (elHeight > curHighest) {
curHighest = elHeight;
}
}).height(curHighest);
});
};
}(jQuery));
// USAGE:
// ********************************************************
// Equal Heights
// ********************************************************
$('.three-col-box .boxes').eqHeights();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment