Skip to content

Instantly share code, notes, and snippets.

@gabriel-felipe
Last active October 12, 2017 16:17
Show Gist options
  • Save gabriel-felipe/6beca139d3d42c1a9cec32238c14efed to your computer and use it in GitHub Desktop.
Save gabriel-felipe/6beca139d3d42c1a9cec32238c14efed to your computer and use it in GitHub Desktop.
Small javascript plugin to make objects have the same height
/*
Usage example:
$(".list > .col-md-4").equalheights();
*/
(function ( $ ) {
$.fn.equalheights = function() {
var maxHeight = 0;
this.each(function(i){
if(parseInt($(this).outerHeight()) > maxHeight){
maxHeight = parseInt($(this).outerHeight());
}
});
this.each(function(i){
height = parseInt($(this).outerHeight());
diff = maxHeight - height;
$(this).css("height",(height+diff)+"px");
});
var selector = this.selector;
};
}( jQuery ));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment