Archive : Equalize heights using jQuery


Archive : Equalize heights using jQuery

Quick code to Equalize Heights of container elements using jQuery. Iterating through each container element specified, compare the height of the container with the value stored in _maxh variable and after the iteration, we apply the new found height to all the container elements.

var _maxh = 0; jQuery('.listing-2 .description').each(function(){ _h = jQuery(this).height(); if( _maxh < _h ) _maxh = _h;

}); jQuery('.listing-2 .description').each(function(){ jQuery(this).height(_maxh); });


Minified
var _maxh=0;jQuery(".listing-2 .description").each(function(){_h=jQuery(this).height(),_maxh<_h&&(_maxh=_h)}),jQuery(".listing-2 .description").each(function(){jQuery(this).height(_maxh)});


Feature photo by Nimit Kansagra