Last active
August 29, 2015 14:22
-
-
Save bih/e9b24dcb09e112058a68 to your computer and use it in GitHub Desktop.
jQuery.matchHeightWith.js - Match two divs heights together.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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