Created
February 20, 2014 16:00
-
-
Save ashhitch/9116998 to your computer and use it in GitHub Desktop.
jQuery functions to make all columns/objects the the same height. Runs through each element and then sets each the the highest one.
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 | |
| $(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); | |
| }); | |
| } | |
| } | |
| $(window).load(function () { | |
| //Pass containing row and item classes | |
| checkAllHeights('.check-height', '.check-height-item'); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment