Last active
July 31, 2018 20:34
-
-
Save dannydickson/3a176f5e2d7915f8b89f3c9be3048e9f to your computer and use it in GitHub Desktop.
Vanilla JS Match Height
This file contains hidden or 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
<script> | |
(function($) { | |
function matchHeight() { | |
function setHeight(elementH) { | |
var maxH = 0; | |
var len = $(elementH).length; | |
$(elementH).css("min-height", ""); | |
$(elementH).each(function (index) { | |
var curH = $(this).outerHeight(); | |
if (curH > maxH) { | |
maxH = curH; | |
} | |
if ((index + 1) == len) { | |
$(elementH).css({ "min-height": maxH }); | |
} | |
}); | |
} | |
setHeight(".et_pb_pricing_content ul"); | |
} | |
function responsiveFn() { | |
matchHeight(); | |
} | |
$(window).load(responsiveFn).resize(responsiveFn); | |
})( jQuery ); | |
</script> |
This file contains hidden or 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
function matchHeight() { | |
function setHeight(elementH) { | |
var maxH = 0; | |
var len = $(elementH).length; | |
$(elementH).css("min-height", ""); | |
$(elementH).each(function (index) { | |
var curH = $(this).outerHeight(); | |
if (curH > maxH) { | |
maxH = curH; | |
} | |
if ((index + 1) == len) { | |
$(elementH).css({ "min-height": maxH }); | |
} | |
}); | |
} | |
setHeight(".woocommerce ul.products li.product > a:first-child"); | |
setHeight(".footer-widgets .widget-area"); | |
setHeight(".woocommerce-page div.product div.thumbnails a"); | |
} | |
function responsiveFn() { | |
matchHeight(); | |
} | |
$(window).load(responsiveFn).resize(responsiveFn); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment