Skip to content

Instantly share code, notes, and snippets.

@Ourelius
Last active August 29, 2015 14:27
Show Gist options
  • Save Ourelius/21cec5536713e33e864d to your computer and use it in GitHub Desktop.
Save Ourelius/21cec5536713e33e864d to your computer and use it in GitHub Desktop.
/***
Equal Heights
***/
function matchHeight() {
var location = $('.row > .container'); // location
location.each(function(i, el){
var set = $('> div', el);
var equal = []; // init an empty array
set.css({'height' : ''}); // reset height for resizeEvent
set.each(function(){
var elementHeight = $(this).height(); // get height of element
equal.push(elementHeight); // push it to array
});
equal.sort(function(a, b){
return b-a; // sorting DESC
});
set.height(equal[0]); // adding equal heights to divs
});
}
$(document).ready(function(){ matchHeight(); });
$(window).on('resize', function(){ matchHeight(); });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment