Skip to content

Instantly share code, notes, and snippets.

@bih
Last active August 29, 2015 14:22
Show Gist options
  • Save bih/e9b24dcb09e112058a68 to your computer and use it in GitHub Desktop.
Save bih/e9b24dcb09e112058a68 to your computer and use it in GitHub Desktop.
jQuery.matchHeightWith.js - Match two divs heights together.
/**
* jQuery function to match two div heights. Disables for mobiles so the experience is better.
*/
$.fn.matchHeightWith = function(jqSelector) {
if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
return;
}
var match_a = $(this).height();
var match_b = $(jqSelector).height();
var changeTo = Math.max(match_a, match_b);
$(this).height(changeTo);
$(jqSelector).height(changeTo);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment