Created
December 17, 2020 07:28
-
-
Save mperlet/6afe3b0d2c015f8b793eed707661c8e3 to your computer and use it in GitHub Desktop.
jQuery calculate parent height by sum up childrens height
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
var parentHeight = $.map($('.parent > *'), function (i) { | |
return ($(i).height()) | |
}).reduce(function (accumulator, currentValue) { | |
return accumulator + currentValue; | |
}, 0); | |
$('.parent').height(parentHeight); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment