Skip to content

Instantly share code, notes, and snippets.

@jlittlejohn
Created March 25, 2014 15:37
Show Gist options
  • Save jlittlejohn/9764432 to your computer and use it in GitHub Desktop.
Save jlittlejohn/9764432 to your computer and use it in GitHub Desktop.
JS: Equalize Heights of an Array of Elements
/*
Loop over all items in a selection
Set tallest item to maxHeight variable
Set height of all elements to maxHeight variable
*/
(function( $ ){
$.fn.equalizeHeights = function() {
var maxHeight = 0;
var el = $(this);
$(el).each(function(){
if($(this).height() > maxHeight) { maxHeight = $(this).height(); }
});
$(el).height(maxHeight);
return this;
};
})( jQuery );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment