jQuery – Equal Column Height

2012-01-04

Here is a simple plugin for jQuery that I wrote the other day. This makes all elements that match the selector get the same height. It may for example be useful to ensure that different columns get the same height. Here is the code and an example of how to use it:

(function($){
	$.fn.fixColumnHeight = function(){
		var maxHeight = 0;
		this.each(function(){
			maxHeight = Math.max(maxHeight, $(this).height());
		});
		this.each(function(){
			$(this).height(maxHeight);
		});
	}
})(jQuery);
$('#column1, #column2, #column3').fixColumnHeight();