Created
March 25, 2014 15:37
-
-
Save jlittlejohn/9764432 to your computer and use it in GitHub Desktop.
JS: Equalize Heights of an Array of Elements
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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