Skip to content

Instantly share code, notes, and snippets.

@OatmealBath
Created September 8, 2014 16:51
Show Gist options
  • Save OatmealBath/8d7a149232f18790b4e3 to your computer and use it in GitHub Desktop.
Save OatmealBath/8d7a149232f18790b4e3 to your computer and use it in GitHub Desktop.
// DEFINE FUNCTION TO KEEP TWO COLUMNS THE SAME HEIGHT
function matchColumnHeight(divone, divtwo, debug){
if(jQuery(divone).length > 0 && jQuery(divtwo).length > 0){
if(debug){
console.log("Div One Original Height: "+jQuery(divone).outerHeight());
console.log("Div Two Original Height: "+jQuery(divtwo).outerHeight());
}
if(jQuery(divone).outerHeight() > jQuery(divtwo).outerHeight()){
jQuery(divtwo).css('min-height',jQuery(divone).outerHeight());
} else {
jQuery(divone).css('min-height',jQuery(divtwo).outerHeight());
}
if(debug){
console.log("Div One New Height: "+jQuery(divone).outerHeight());
console.log("Div Two New Height: "+jQuery(divtwo).outerHeight());
}
}
}
// ON WINDOW LOAD MATCH HEIGHTS
jQuery(window).load(function(){
matchColumnHeight('INSERT FIRST CLASS OR ID HERE','INSERT SECOND CLASS OR ID HERE',false);
});
// ON WINDOW RESIZE MATCH HEIGHTS
jQuery(window).resize(function(){
matchColumnHeight('INSERT SECOND CLASS OR ID HERE','INSERT SECOND CLASS OR ID HERE',false);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment