Created
April 30, 2014 10:05
-
-
Save ashhitch/01958abd23c1e31bc5c9 to your computer and use it in GitHub Desktop.
Function to make all elements within a wrapper, the same height with jQuery.
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 checkAllHeights(row, item) { | |
| if ($(row).length !== 0) { | |
| var itemHeight = 0; | |
| //reset size | |
| $(row + ' ' + item).removeAttr('style'); | |
| //Check heights to get tallest | |
| $(row + ' ' + item).each(function (index) { | |
| if (($(this).height() > itemHeight)) { | |
| itemHeight = $(this).height(); | |
| } | |
| }).promise().done(function () { | |
| //Once done set all to the highest | |
| $(row + ' ' + item).height(itemHeight); | |
| }); | |
| } | |
| } |
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
| //onLoad | |
| $(window).load(checkAllHeights('.row-class', '.item-class')); | |
| //onResize | |
| $(window).resize(checkAllHeights('.row-class', '.item-class')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment